IE兼容笔记

235 阅读1分钟

1 IE会缓存get请求,

axios拦截器统一增加时间戳,避免每一个请求都写一遍。

2 strict 模式下不允许分配到只读属性

修改dom属性写法

var xx = document.createElement('div') 创建了一个元素

错误:不能直接xx.style=''赋值

正确:需要改成这种方式xx.style.height='6px'的方式

3  rgba(0,0,0),不写透明度时,在chrome也可以识别,

但是IE不能识别,所以改成rgb(0,0,0)

4 IE 不支持remove()方法

 fixIERemove(){
   if (!('remove' in Element.prototype)) {
     Element.prototype.remove = function() {
      if (this.parentNode) {
       this.parentNode.removeChild(this);
   }
  };
 }
},

5 checkbox 选中问题

//修改前,复选框选中有问题

<span @click="checkRiskTypeAction(item.value)" class="level2-item" v-for="(item) in riskTypeList" :key="item.value"><input type="checkbox" :value="item.value" :data-val="item.value"v-model="selectedRiskTypeList"><span  :class="'item-value '+(selectedRiskTypeList.indexOf(item.value)>-1?'selected':'')">{{item.name}}</span></span>

//修改后”事件绑定“移到子元素;

<span class="level2-item" v-for="(item) in riskTypeList" :key="item.value">                                    <input type="checkbox" :value="item.value" :data-val="item.value"                                        v-model="selectedRiskTypeList">                                    <span  @click="checkRiskTypeAction(item.value)" :class="'item-value '+(selectedRiskTypeList.indexOf(item.value)>-1?'selected':'')">{{item.name}}</span>                                </span>