热门搜索:
var path = require('path'); //合法的字符串连接 path.join('/foo','bar','baz/asdf','quux','..') 连接后 '/foo/bar/baz/asdf' 不合法的字符串将抛出异常 path.join('foo',{},'bar' 抛出的异常 TypeError: Arguments to path.join must be strings'
path.resolve('foo/bar','/tmp/file/','..','a/../subfile')
cd foo/bar cd /tmp/file/ cd .. cd a/../subfile pwd
path.resolve('/foo/bar','./baz' 输出结果为 '/foo/bar/baz' path.resolve('/foo/bar','/tmp/file/' 输出结果为 '/tmp/file' path.resolve('wwwroot','static_files/png/','../gif/image.gif' 当前的工作路径是 /home/itbilu/node,则输出结果为 '/home/itbilu/node/wwwroot/static_files/gif/image.gif'
const path = require('path'); let myPath = path.join(__dirname,'/img/so'); let myPath2 = path.join(__dirname,'./img/so'); let myPath3 = path.resolve(__dirname,1)">); let myPath4 = path.resolve(__dirname,1)">); console.log(__dirname); D:\myProgram\test console.log(myPath); D:\myProgram\test\img\so console.log(myPath2); D:\myProgram\test\img\so console.log(myPath3); D:\img\so<br> console.log(myPath4); D:\myProgram\test\img\so
本站采用系统自动发货方式,付款后即出现下载入口,如有疑问请咨询在线客服!
咨询售后客服