When the el-dialog is opened in the vue project, it is only loaded once, and the el-table flickers when switching components

<el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="deleData" width="825px" :show-close="false" top="0vh" custom-class="center-dialog" :modal-append-to-body="false">

</el-dialog>

The mounted component is only triggered once, and it can only take effect when the dialog box is opened for the first time. You need to add v-if="deleData"

When switching components, el-table will flash, and the visual experience is very bad. Add a key value to el-table and mark it as a different table to solve the problem

//template部分

<el-table :data="tableData" class="table" :key="tableKey" :header-cell-style="{ 'background': '#F4F4F4', 'font-size': '16px','font-weight': '400', 'color': '#37474F' }" :row-style="{'color': '#688696'}" highlight-current-row>
</el-table>
script部分

data(){
  return{
      tableKey:0,
  }
}

methods:{
//切换组件时改变key值
 changeTab(n){
     if(n == 0){
        this.tableKey = 0
     }else{
        this.tableKey = 1
     }
 },
}

Secondly, using v-show when switching components will also cause the page to flicker, which can be solved by using v-if

Guess you like

Origin blog.csdn.net/m0_65835778/article/details/128875127