4 回答
TA贡献1780条经验 获得超5个赞
const format = (/\.(\S+)$/.exec(res) || [,''])[1].toLowerCase()
const iconMap = {
_default: 'war_icon.png',
doc: 'word.png',
docx: 'word.png',
pdf: 'pdf_icon.png',
rar: 'rar_icon.png',
tif: 'tif_icon.png',
xls: 'xls_icon.png',
xlsx: 'xls_icon.png',
zip: 'rar_icon.png',
}
const cache = require(`../assets/inmages/FileTypeIcon/${iconMap[format] || iconMap._default}`)
TA贡献1779条经验 获得超6个赞
var cache = ''
if (/^docx?$/i.test(format)) {
} else if (/^pdf$/i.test(format)) {
} else if (/^(zip|rar)$/i.test(format)) {
} else if (/^xlsx?$/i.test(format)) {
} else if (/^tif$/i.test(format)) {
} else {
}
TA贡献1859条经验 获得超6个赞
var cache = require('../assets/inmages/FileTypeIcon/'+(
['doc','DOC','docx','DOCX'].includes(format)?"word"
:['pdf','PDF'].includes(format)?"pdf_icon"
:['zip','ZIP','rar'].includes(format)?"rar_icon"
:['xls','XLS','xlsx','XLSX'].includes(format)?"xls_icon"
:['tif','TIF'].includes(format)?"tif_icon":"war_icon"
)+'.png')
TA贡献1851条经验 获得超5个赞
function docType(str){
let cache = '';
str = str.toLowerCase();
switch(str){
case 'doc':
case 'docx:
cache = '../assets/images/filetypeIcon/word.png'
break;
case 'pdf':
cache = '../assets/images/filetypeIcon/pdf_icon.png'
break;
....
defalut:
cache = '../assets/images/filetypeIcon/war_icon.png';
};
return cache;
}
添加回答
举报