就是它这个table怎么绑定php绑定mysql的数据额,也没看到有文档
<template>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
prop="date"
label="日期"
width="180">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="180">
</el-table-column>
<el-table-column
prop="address"
label="地址">
</el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}]
}
}
}
</script>
1.绑定一条数据用: => slot-scope属性,再显示对应的数据
通过 Scoped slot 可以获取到 row, column, $index 和 store(table 内部的状态管理)的数据:
{{scope.row}} =>获取整行的数据
{{scope.$index}} => 行的下标
使用:
<el-table <el-table-column
<template slot-scope="scope">
{{ scope.row.userSex === 1 ? "男" : "女" }} </template>
/el-table-column>
/el-table>
2.只绑定一个数据,例如:sex:'女'
<ui-table-column prop="userSex" label="性别" width="80px" :formatte r="getSexType" show-overflow-tooltip> </ui-table-column>
再通过formatter属性来格式化数据(定义没有数据的显示内容)如下:
getSexType(row, column) { return sexType(row[column.property]) }
row[column.property] => 获取表格里数据
sexType => 定义的公共方法(逻辑)
没用过php,用的vue,不过一般都是通过ajax(我用的axios)从后台获取tableData这个数据,
注意格式一致就行,可以多一些属性,但是不能少,
每次前台有增删改查之后就从后台获取一次