前端vue项目在IE11上的兼容问题总结

 

1. sockjs报错

  1. 找到/node_modules/sockjs-client/dist/sockjs.js
  2. 找到代码的 1606行,注释掉即可

2. 报语法错误,打开空白屏

  1. 安装 babel-polyfill

    npm install babel-polyfill --save 

  2. 在main.js中引入babel-polyfill

    import 'babel-polyfill'
  3. 重启项目 

3. 兼容IE11的下载功能

     downloadTask(params).then(res => {
       // 判断IE11下用window.navigator.msSaveBlob方式
       if (window.navigator.msSaveBlob) {
          try {
            window.navigator.msSaveBlob(res, `${row.jobName}.json`);
          } catch (e) {
            console.error(e);
          }
        } else {
         // 其他浏览器下用这种方式
          const fileName = `${row.jobName}.json`;
          const _res = res.data;
          const blob = new Blob([_res]);
          const downloadElement = document.createElement('a');
          const href = window.URL.createObjectURL(blob); // 创建下载的链接
          downloadElement.href = href;
          downloadElement.download = decodeURI(fileName); // 下载后文件名
          document.body.appendChild(downloadElement);
          downloadElement.click(); // 点击下载
          document.body.removeChild(downloadElement); // 下载完成移除元素
          window.URL.revokeObjectURL(href); // 释放掉blob对象
        }
      });

4. 兼容IE11的样式写法

      IE11不能够识别样式中的计算属性calc,因此需要针对IE11额外设置样式。

@media screen and(-ms-high-contrast:active), (-ms-high-contrast: none){

   //   在这里面写IE的样式,只有IE能识别到

}

  .demo-scrollbar-wrap {
    max-height: ~'calc(100% - 19px)';
    @media screen and(-ms-high-contrast:active), (-ms-high-contrast: none) {
      max-height: 100%;
    }
  }

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值