type check failed for prop “property“. Expected String with value “0“, got Number with value 0.

问题:使用el-table时报多个如下错误

type check failed for prop “property“. Expected String with value “0“, got Number with value 0.

问题原因:数据类型不匹配,他要的是String类型,但数据是Number,就会报这个错

原来的写法

<el-table :data="fywz.data" max-height="600" style="z-index: 99004">
          <el-table-column
            :label="key.name"
            :property="key.index"
            :key="index"
            v-for="(key, index) in fywz.columnList"
          >
            <template slot-scope="scope">
              <div class="cell-item">
                {
   
   { scope.row[scope.column.property] }}
              </div>
            </template>
          </el-table-column>
        </el-table>

修改后

<el-table :data="fywz.data" max-height="600" style="z-index: 99004">
          <el-table-column
            :label="key.name"
            :property="key.index|indexInfo"
            :key="index"
            v-for="(key, index) in fywz.columnList"
          >
            <template slot-scope="scope">
              <div class="cell-item">
                {
   
   { scope.row[scope.column.property] }}
              </div>
            </template>
          </el-table-column>
        </el-table>
//用过滤器将数据类型转换为String
filters: {
    
    
	indexInfo: function(value){
    
    
      return value.toString();
    }
}

参考:https://blog.csdn.net/bamboolm/article/details/122494495

猜你喜欢

转载自blog.csdn.net/qq_44862029/article/details/125446880
今日推荐