vue ant table customRender 不能用this访问内部数据的解决

数据中有 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;
            }
          }

猜你喜欢

转载自blog.csdn.net/wyljz/article/details/106526831
今日推荐