这个错误提示表明您在使用 endWith
方法,但正确的方法应该是 endsWith
。
let name = 'cxk03.gif.png'
let arr = name.split('.')
/*let ext = arr[arr.length - 1]
console.log(ext)*/
//数组转换成字符串
let ext = arr.toString()
console.log(ext.endWith('gif'))
您需要将代码中的 endWith
修改为 endsWith
,例如:
let name = 'cxk03.gif.png'
let arr = name.split('.')
/*let ext = arr[arr.length - 1]
console.log(ext)*/
//数组转换成字符串
let ext = arr.toString()
console.log(ext.endsWith('gif').toString())