Not much to say, just go to the solution
The first step is to install af-table-column
npm install af-table-column
The second step is introduced in main.js
import Vue from 'vue'
import ElementUI from 'element-ui'
import AFTableColumn from 'af-table-column'
Vue.use(AFTableColumn) //注意,先引用vue再引入elementui
Finally used in the component
<el-table stripe :data="tableData" v-loading="tLoading">
<af-table-column label="姓名" align="center" prop="name">
</af-table-column>
<af-table-column label="年龄" align="center" prop="age">
</af-table-column>
<el-table>
In the project development, I found that the fit attribute of the table in elementui does not work (whether the width of the column is self-supporting), and setting the width of each column is not the main solution to the problem. Baidu later discovered that it uses a table-column column component that supports adaptive column widths based on Element-UI secondary packaging github link af-table-column