How can I convert a windows path to posix path using node path

前端 未结 5 910
心在旅途
心在旅途 2021-01-03 23:28

I\'m developing on windows, but need to know how to convert a windows path (with backslashes \\) into a POSIX path with forward slashes (/)?

<
5条回答
  •  猫巷女王i
    2021-01-03 23:41

    const winPath = 'C:\\repos\\vue-t\\tests\\views\\index\\home.vue'
    const posixPath = winPath.replace(/\\/g, '/').slice(2)
    // Now posixPath = '/repos/vue-t/tests/views/index/home.vue'
    

提交回复
热议问题