Skip to content

Function: dirname() ​

ts
function dirname(path): string;

获取路径中的目录部分。

Parameters ​

ParameterTypeDescription
pathstring要处理的路径

Returns ​

string

路径的目录部分

Example ​

ts
dirname('/foo/bar/baz.html') // => '/foo/bar'
dirname('/foo/bar/baz')      // => '/foo/bar'
dirname('/foo/bar/')         // => '/foo'
dirname('/foo')              // => '/'
dirname('foo')               // => '.'

Since ​

1.0.0

Released under the MIT License.