首页 新闻 会员 周边

vue跨域获取数据库中的值,判断数据库的值是0还是1,如果是1就选择复选框,否则反之

0
[已解决问题] 解决于 2022-06-30 16:17

<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></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>

js代码 构造函数
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-29 22:05
< >
分享
最佳答案
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:09

谢谢,已解决

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