el-upload + accept限制上传的文件格式



/**
 * kevin 2021/1/4
 * @description el-upload + accept限制上传的文件格式
 * @param e 校验的类型
 * @returns {string | null}
 */
export function acceptFile(e) {
  const allowHook = {
    video: '.mp4, .ogv, .ogg, .webm',
    audio: '.wav, .mp3, .ogg, .acc, .webm, .amr',
    file: 'doc,.docx,.xlsx,.xls,.pdf',
    excel: 'xlsx,.xls',
    img: '.jpg, .jpeg, .png, .gif'
  }
  if (e) {
    return allowHook[e]
  }
  let srt = null
  for (const k in allowHook) {
    srt += allowHook[k]
  }
  return srt
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM