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;
            }
          }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章