path.basename(path,[ext])
<string>
<string>
可选的文件扩展名<string>
const path = require('path') const url = 'C:\\temp\\myfile.html' //未输入文件扩展名时会显示文件名+扩展名 path.basename(url); //Returns:'myfile.html' //输入文件扩展名时只显示文件名 path.basename(url,'.html') //Returns:'myfile'
path.extname(path)
<string>
<string>
const path = require('path') const url = 'C:\\temp\\myfile.html' path.extname(url) //Returns:'.html'
path.dirname(path)
<string>
<stirng>
const path = require('path') const url = 'C:\\temp\\myfile.html' path.dirname(url) //Returns:'C:\\temp'
path.join([…paths])
<string>
目录路径序列<stirng>
const path = require('path') path.join('C:\\','temp') //Returns:'C:\\temp'