path.dirname(path)
版本历史
| 版本 | 变更 |
|---|---|
| v6.0.0 | 传入非字符串作为 |
| v0.1.16 | 新增于: v0.1.16 |
path.dirname() 方法返回 path 的目录名,类似于 Unix dirname 命令。尾随的目录分隔符被忽略,见 path.sep。
\The path.dirname() method returns the directory name of a path, similar to
the Unix dirname command. Trailing directory separators are ignored, see
path.sep.
path.dirname('/foo/bar/baz/asdf/quux');
// Returns: '/foo/bar/baz/asdf' 如果 path 不是字符串,则抛出 TypeError。
\A TypeError is thrown if path is not a string.