Safari browser element table header and content are misaligned

1. Get dom

<el-table
  ref="testTab"
:data="tableData" 
>`
</el-table>

2. Dynamically set the tableLayou value after the table rendering is completed.

//请求列表
this.$get(apiName).then(res=>{
	 this.setTabFixedLayout()
})

// 动态设置table-body样式
    setTabFixedLayout(){
      var tempDiv=this.$refs.testTab.$el.children;
      for(let i=0;i<tempDiv.length;i++){
        let t_className=tempDiv[i].className;
        if(t_className && t_className.indexOf("el-table__header-wrapper")!=-1 || t_className.indexOf("el-table__body-wrapper")!=-1){
          let t_divObj=tempDiv[i].children;
          if(t_divObj){
            for(let j=0;j<t_divObj.length;j++){
              let t_className_2=t_divObj[j].className;
              if(t_className_2 && t_className_2.indexOf("el-table__header")!=-1 || t_className_2.indexOf("el-table__body")!=-1){
                t_divObj[j].style.tableLayout="auto";
                window.setTimeout(()=>{
                  t_divObj[j].style.tableLayout="fixed";
                },20);
              }
            }
          }
        }
      }
    }, 

Guess you like

Origin blog.csdn.net/weixin_42215897/article/details/125317443