输入
const path0 = path.resolve(ROOT_PATH, 'docs');
const path1 = path.resolve(ROOT_PATH, '/docs');
const path2 = path.resolve(ROOT_PATH, './docs');
const path3 = path.join(ROOT_PATH, './docs');
const path4 = path.join(ROOT_PATH, '/docs');
const path5 = path.join(ROOT_PATH, 'docs');
console.log(path0);
console.log(path1);
console.log(path2);
console.log(path3);
console.log(path4);
console.log(path5);
输出
G:\编程测试练习\11-18\docs
G:\docs
G:\编程测试练习\11-18\docs
G:\编程测试练习\11-18\docs
G:\编程测试练习\11-18\docs
G:\编程测试练习\11-18\docs
总结
- path.resolve 中 'doc' 和 './doc' 等价。
- path.join 中 'doc' 、'/doc' 和 './doc' 三者等价。