方法说明: 将参数 to 位置的字符解析到一个绝对路径里。 语法: path.resolve([from ...], to) 由于该方法属于path模块,使用前需要引入path模块(var path=
方法说明:
将参数 to 位置的字符解析到一个绝对路径里。
语法:
path.resolve([from ...], to)
由于该方法属于path模块,使用前需要引入path模块(var path= require(“path”) )
接收参数:
from 源路径
to 将被解析到绝对路径的字符串
例子:
path.resolve('/foo/bar', './baz')
// returns
'/foo/bar/baz'
path.resolve('/foo/bar', '/tmp/file/')
// returns
'/tmp/file'
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
// if currently in /home/myself/node, it returns
'/home/myself/node/wwwroot/static_files/gif/image.gif'
另一种方法是把它作为一个序列的cd命令shell。
path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile')
类似于:
cd foo/bar
cd /tmp/file/
cd ..
cd a/../subfile
pwd
--结束END--
本文标题: node.js中的path.resolve方法使用说明
本文链接: https://www.lsjlt.com/news/11976.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