首页 新闻 会员 周边

vue中根据axios获取数据库中的值来判断是否选中复选框

0
悬赏园豆:50 [已解决问题] 解决于 2022-06-23 17:24

<!-- 角色管理数据显示 -->
<el-table
:data="tableData"
style="width: 60%;margin-top:10px;">
<el-table-column
prop="date"
label="选择"
width="180">
<template slot-scope="scope">
<el-radio v-model="templateradio" :label="scope.$index+null" @change.native="getTemplateRow(scope.$index,scope.row)"></el-radio>
</template>
</el-table-column>
<el-table-column
prop="name"
label="角色编号"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.roleCode }}</span>
</template>
</el-table-column>
<el-table-column
prop="address"
label="角色名称">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.roleName }}</span>
</template>
</el-table-column>
<el-table-column
prop="address"
label="创建人">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.createdBy }}</span>
</template>
</el-table-column>
<el-table-column
prop="address"
label="状态(启用/禁用)">
<template slot-scope="scope">
<el-checkbox :true-label="1" :false-label="0" v-model="check"></el-checkbox>
<span style="margin-left: 10px">{{ scope.row.isStart }}</span>
</template>
</el-table-column>
<el-table-column
prop="address"
label="最后修改时间">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.createDate }}</span>
</template>
</el-table-column>
</el-table>

export default {
name:'ShowTable',
data() {
return {
tableData: [],//存放数据库查询的数据
templateradio:false,
indexs:0,
dialogVisible: false,//添加角色dialog对话框状态 关闭
dialogVisible2:false,//修改角色dialog对话框状态 关闭
radio:'1',//添加角色dialog对话框角色状态
radios:'1',//修改角色dialog对话框角色状态
check:0,
checks:false,
}
},methods:{
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
.catch(_ => {});
},
getTemplateRow(index, row) {
this.templateSelection = row;
this.indexs=index;
}
},created(){
console.log(1);
let _this=this;
//Vue对象创建完毕后的钩子函数
axios.post("/SL/GetRole",null).then(function(res){
//请求成功的处理函数
_this.$data.tableData=res.data;
}).catch(function(res){
//请求失败的处理函数

  });
}

}

宋人鱼的主页 宋人鱼 | 初学一级 | 园豆:14
提问于:2022-04-30 16:51
< >
分享
最佳答案
0

换了个方式
<el-table-column
prop="address"
label="状态(启用/禁用)">
<template slot-scope="scope">
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.isStart"></el-checkbox>
</template>
</el-table-column>
根据获取数据库中的值,是否是true-lable(选中时的值),如果是则选中,如果不是则不选择

宋人鱼 | 初学一级 |园豆:14 | 2022-04-30 17:08

好的,已解决

宋人鱼 | 园豆:14 (初学一级) | 2022-06-24 17:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册