1.带后缀名
function getFileName(path){
var pos1 = path.lastIndexOf(‘/‘);
var pos2 = path.lastIndexOf(‘\\‘);
var pos = Math.max(pos1, pos2)
if( pos<0 )
return path;
else
return path.substring(pos+1);
}
原文链接:https://blog.csdn.net/qaakd/article/details/108058545
2.不带后缀名
原文:https://www.cnblogs.com/maycpou/p/14830850.html