灵心如玉,守一生无惧|

SadicZhou

园龄:3年2个月粉丝:7关注:4

node3_path.join和path.basename、path.extname用法

  

 

 path.basename用法:

1
2
3
4
5
6
const Path =require('path')
const fullPath = 'a/b/index.html'
let name = Path.basename(fullPath)//index.html,第一个参数是获取带有后缀的文件名
console.log(name)
name = Path.basename(fullPath,'.html')//第二个参数是去掉文件名的后缀
console.log(name)

  

 

1
2
3
4
5
const path = require('path')
const fullPath= 'a/b/index.html'
const ext = path.extname(fullPath)
console.log(ext)
//获取文件后缀

  

 

本文作者:SadicZhou

本文链接:https://www.cnblogs.com/SadicZhou/p/16847239.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   SadicZhou  阅读(40)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 尚好的青春 孙燕姿
  2. 2 孙燕姿
  3. 3 克卜勒 孙燕姿
- 孙燕姿
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.