VUE项目兼容IE11 遇见的问题 SyntaxError: strict 模式下不允许一个属性有多个定义;ie11下载excel文件需要用navigator.msSaveBlob

最近要把vue项目兼容ie11 前面引入bable等一系列操作就不说了,下面说一下具体具体的问题

1  如图所示  SyntaxError: strict 模式下不允许一个属性有多个定义, 点击stack所在行后面的省略号 出现具体的vue文件

可以看到 dirTuihuibz.vue里面有属性重复问题

<el-form-item label="设备类型">
  <el-select v-model="equipmentId" placeholder=""  clearable @clear="getdirCheHuiTables" placeholder="请选择设备类型名称">
    <el-option
      v-for="item in equipInfoOptions"
      :key="item.id"
      :label="item.descrbution"
      :value="item.descrbution">
    </el-option>
  </el-select>
</el-form-item>

可以看到我有2个placeholder 删掉没有用的placeholder就可以了

 

2 级联选择器在禁用状态下回显内容不显示

 

.el-cascader__tags .el-tag{
  display: inline;
}

给 span 标签 加上display:inline

 

3 ie11下载excel文件需要用navigator.msSaveBlob(blob,contentDispositionFileName)

//下载excle
downloadExcel(){
  this.$axios({
    url: this.api.api_eventdeclartion.downloadExcel+'?subject='+this.searchObj.title+'&id='+this.searchObj.bizKey,
    method: 'post',
    responseType: 'blob',
  })
    .then((response) => {
      const data =response.data
      let r = new FileReader()
      r.onload = function () {
        try {
          let  resData = JSON.parse(this.result)
          if(resData.code){
            if(resData.code==401){
              localStorage.clear();
              window.open(resData.redirectUrl,'_self');
            }
          }
        } catch (e) {
        }
      }
      r.readAsText(data)
      this.download(response);
    })
    .catch((error) => {
    });

},
download(data) {
  if (!data) {
    return
  }
  var blob = new Blob([data.data])
  var aLink = document.createElement("a");
  const contentDisposition = data.headers['content-disposition'];
  const contentDispositionFileName = decodeURI(contentDisposition.split('=')[1]);
  if (!!window.ActiveXObject || "ActiveXObject" in window || navigator.userAgent.indexOf("Edge") > -1) {
    navigator.msSaveBlob(blob,contentDispositionFileName)
  } else {
    var url = window.URL.createObjectURL(blob);
    aLink.style.display = "none";
    aLink.download=contentDispositionFileName
    aLink.href = url;
    document.body.appendChild(aLink)
    aLink.click()
  }
},

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值