关于slot.row没有彻底理解,暂且先挖个坑,后面学习明白了再补充一下.数组
<el-table :data="userList" stripe style="width: 100%"> <el-table-column prop="username"label="姓名" width="180"></el-table-column> <el-table-column prop="email" label="邮箱" width="180"> </el-table-column> <el-table-column prop="mobile" label="电话"> </el-table-column> <el-table-column label="用户状态"> <template slot-scope="scope"> <el-switch v-model="scope.row.mg_state" @change="userstateChange(scope.row.id, scope.row.mg_state)"> </el-switch> </template> </el-table-column> <el-table-column prop="adress" label="操做"> </el-table-column> </el-table>
1.-------------> :data="userList"学习
表格绑定了用于存储数据的数组,里面每个元素都是数据对象spa
2.-------------> slot-scope="scope"code
这是做用域插槽中定义一个对象(这里对象被定义为scope)来存储插槽上绑定的数据的用法对象
3.-------------> scope.rowblog
在这里使用ElementUI表格模板渲染数据时,ip
"当前行数据的获取也会用到插槽,scope至关于一行的数据, scope.row至关于当前行的数据对象,"(这是在网上看到的一个解释,暂且记下)作用域