path
2023-03-03 本文已影响0人
陌小亓
..与.和平常用法一样
..
指上一级路径
.
指当前路径
const path = require('path')
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
// Returns: '/foo/bar/baz/asdf'
path.join('/foo', 'bar', 'baz/asdf', 'quux', '.');
// Returns: '/foo/bar/baz/asdf/quux'
path.join('/foo', 'bar', 'baz/asdf', 'quux', '../');
// Returns: '/foo/bar/baz/asdf/'
const url = path.join('/foo', 'bar', 'baz/asdf', '..', 'abc');
// Returns: '/foo/bar/baz/abc'