Reference: https://blog.csdn.net/weixin_36706903/article/details/81706857
me backstage data format like this
. I'm in my method is written ($ http is packaged ajax, may everyone the naming convention is not the same)
this.$http({
url: this.$http.adornUrl('后台返回连接地址'),
method: 'get',
params: this.$http.adornParams({
'keyword': '男',
'page': 1,
'limit': 10
})
}).then(({data}) => {
this.tableData = data.page.list // 注意这里,后台返回的json格式不一样写的就不一样
console.log(JSON.stringify(data))
}).catch(function (error) {
console.log(error)
})
In the element table will have a corresponding modification (pull the scroll bar to the right, I have notes)
<el-table 。。此处省略参考原博主。。 :data="tableData" >
<el-table-column label="序号" prop="id" type="index" sortable="custom" align="center" width="80px" ></el-table-column> // id就直接这样写了
<el-table-column label="学校" width="130px" align="center" prop="school_name"> </el-table-column> //school_name在list中,上边的方法已经写了 this.tableData = data.page.list ,直接写就可以
<el-table-column label="姓名" width="130px" align="center" prop="list"> //这是第二种多此一举了,先prop一下list,在scope.row.xm也可以
<template slot-scope="scope">
<span>{{scope.row.xm}}</span>
</template>
</el-table-column>
Again note that
data(){
return{
tableData: [] //这里是中括号,别瞎写
}
}