字符串截取最后一个" . "或者最后一个" / " 之后的字符
常用于截取文件名,或者文件后缀
let lis = res.data.data.rows for (let i = 0; i < lis.length; i++) { const splitArray = lis[i].projectFileStr.split('/') const substring = splitArray[splitArray.length - 1] lis[i].name = substring const Arrays = lis[i].projectFileStr.split('.') const substr = Arrays[Arrays.length - 1] console.log(substr) lis[i].format = substr } list.value = lis
//示例
let string = 'yellow.png' const Arrays =string.split('.') const substr = Arrays[Arrays.length - 1] console.log(substr) //打印出来 'png'