1
0
Fork 0
Browse Source

vault backup: 2022-08-02 11:40:57

master
YuJian 2 years ago
parent
commit
5312cc07e3
  1. 11
      随时随地/Nodejs 文件系统(path)学习笔记.md

11
随时随地/Nodejs 文件系统(path)学习笔记.md

@ -291,4 +291,13 @@ const changeFilenameExtension = (pathStr, newExtension) => { @@ -291,4 +291,13 @@ const changeFilenameExtension = (pathStr, newExtension) => {
- 必须使用相对路径
- 跨平台复用时确保路径分隔符的正确
###
### 与平台无关的相对路径(Relative platform-independent paths)
与平台无关的相对路径可以存储在一个数组中,可以使用以下的方法转换为对应平台的路径
```javascript
const universalRelativePath = ['static', 'img', 'logo.jpg'];
const dataDirUnix = '/home/john/data-dir';
path.posix.resolve(dataDirUnix, ...universalRelativePath),
// '/home/john/data-dir/static/img/logo.jpg'
```
Loading…
Cancel
Save