vue ant table customRender 不能用this访问内部数据的解决
数据中有 type 字段,需根据值取出显示项,customRender中用this访问不到data中定义的数组,将数组定义在script中就可以了<script>let liveTypes = [];export default {...data() {return {innerColumns: [...{title: '类型',align: 'center',
·
数据中有 type 字段,需根据值取出显示项,customRender中用this访问不到data中定义的数组,将数组定义在script中就可以了
<script>
let liveTypes = [];
export default {
...
data() {
return {
innerColumns: [
...
{
title: '类型',
align: 'center',
dataIndex: 'liveType',
customRender: function (text, record, index) {
for (let i = 0; i < liveTypes.length; i++) {
if (liveTypes[i].value == record.liveType) {
return liveTypes[i].text;
}
}
return text;
}
}
更多推荐
已为社区贡献11条内容
所有评论(0)