vue ant table customRender 不能用this访问内部数据的解决
原创
©著作权归作者所有:来自51CTO博客作者山阳糊涂的原创作品,请联系作者获取转载授权,否则将追究法律责任
数据中有 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;
}
}