let _suffix = res.fileExt || res.fileExt.substring(1); console.log(res.fileExt.substring(1)) if (_suffix == 'jpeg' || _suffix == 'jpg' || _suffix == 'png' || _suffix == 'bmp'|| _suffix == 'gif' ) { alert(1); this.fileDetail.iFileType = 'img' }else if(_suffix == 'mov' || _suffix == 'avi' || _suffix == 'rm' || _suffix == 'rmvb' || _suffix == 'mpeg' || _suffix == 'mpg'){ this.fileDetail.iFileType = 'video' }else{ this.fileDetail.iFileType = 'none' }
1 回答
九州编程
TA贡献1785条经验 获得超4个赞
『 Javascript 策略模式 』
const _suffix = res.fileExt || res.fileExt.substring(1)
const img = 'img'
const video = 'video'
const mapping = {
jpeg: img,
jpg: img,
png: img,
bmp: img,
gif: img,
mov: video,
avi: video,
rm: video,
rmvb: video,
mpeg: video,
mpg: video,
}
this.fileDetail.iFileType = mapping[_suffix] || 'none'
添加回答
举报
0/150
提交
取消