方法说明: 返回path的目录。类似于UNIX目录命令。 语法: path.dirname(p) 由于该方法属于path模块,使用前需要引入path模块(var path= require(“path”
方法说明:
返回path的目录。类似于UNIX目录命令。
语法:
path.dirname(p)
由于该方法属于path模块,使用前需要引入path模块(var path= require(“path”) )
接收参数:
p path地址
例子:
var path= require("path");
path.dirname('/foo/bar/baz/asdf/quux')
// returns
'/foo/bar/baz/asdf'
源码:
exports.dirname = function(path) {
var result = splitPath(path),
root = result[0],
dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
return '.';
}
if (dir) {
// It has a dirname, strip trailing slash
dir = dir.substr(0, dir.length - 1);
}
return root + dir;
};
--结束END--
本文标题: node.js中的path.dirname方法使用说明
本文链接: https://www.lsjlt.com/news/12069.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2022-06-04
2022-06-04
2022-06-04
2022-06-04
2022-06-04
2022-06-04
2022-06-04
2022-06-04
2022-06-04
2022-06-04
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0