node.js中的path.basename方法使用说明
方法说明:
提取出用‘/'隔开的path的最后一部分。(8详见例子)
语法:
path.basename(p,[ext])
由于该方法属于path模块,使用前需要引入path模块(varpath=require(“path”))
接收参数:
p 要处理的path
ext 要过滤的字符
例子:
varpath=require("path");
path.basename('/foo/bar/baz/asdf/quux.html')
//returns
'quux.html'
path.basename('/foo/bar/baz/asdf/quux.html','.html')
//returns
'quux'
vara=path.basename('/foo/bar/baz/asdf/','.html');
//returns
'asdf'
热门推荐
2 红丝绒戚风蛋糕
3 夹心小甜点
4 南瓜甜点
6 粘米粉蒸蛋糕
7 酸奶华夫饼
9 红柚鸡蛋糕
10 葡萄干蛋糕
11 紫薯蛋糕卷
13 纸杯裱花小蛋糕
14 果酱奶酪蛋糕
15 日式樱花蔓越莓大福
16 草莓蛋糕卷
17 卡仕达长崎杯子蛋糕