js通过正则表达式,获取文件类型
getFileType (url) { let pdfReg = /^.+(\.pdf)$/ let txtReg = /^.+(\.txt)$/ let wordReg = /^.+(\.doc|\.docx)$/ let excelReg = /^.+(\.xls|\.xlsx)$/ let jpgReg = /^.+(\.png|\.jpg|\.jpeg|\.bmp)$/ if (pdfReg.test(url)) { return 'pdf' } if (txtReg.test(url)) { return 'txt' } if (wordReg.test(url)) { return 'word' } if (excelReg.test(url)) { return 'excel' } if (jpgReg.test(url)) { return 'picture' } }