Files
nodejs/test1/path/path.parse.js
T
2026-08-23 23:25:17 +08:00

12 lines
680 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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))