|
|
|
@ -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' |
|
|
|
|
``` |