从后端返回一个数组,想要获取文件url后缀,怎样返回?
var arr = [{id:1,fileUrl:'http://lalallala.com/files/6894489vvv38306048.xlsx'},
{id:2,fileUrl:'http://lalallala.com/files/6894489dddsw2738306048.doc'},
{id:3,fileUrl:'http://lalallala.com/files/68944892738geg306048.pdf'},
{id:4,fileUrl:'http://lalallala.com/files/68944dszggf892738306048.ppt'}]
arr.map((value)=>{
var endUrl = value.fileUrl.substring(value.fileUrl.lastIndexOf(".")+1)
value.type = endUrl
return value
})
console.log(arr)