Files

12 lines
680 B
JavaScript
Raw Permalink Normal View History

2026-08-23 23:21:07 +08:00
const path=require('path');
var testPath='f:code/node/chenxuan.js'
const mypath1=path.join(__dirname,'/hehe1','/hehe2','/hehe3.html');
console.log(mypath1)
// path.parse 将路径解析为对象,包含5个字段:
// root - 根目录,macOS/Linux 为 '/',Windows 为盘符如 'C:\'
// dir - 文件所在完整目录路径(不含文件名),等价于 path.dirname()
// base - 完整文件名(名称+扩展名),等价于 path.basename()
// ext - 文件扩展名(从最后一个点开始),如 '.html',等价于 path.extname()
// name - 纯文件名(不含扩展名),等价于去掉 ext 后的 basename
console.log(path.parse(mypath1))