zoukankan      html  css  js  c++  java
  • el-table-column v-if条件渲染报错h.$scopedSlots.default is not a function

    我们在实际项目中经常会遇到el-table-column条件渲染出现报错的情况

    报错内容: h.$scopedSlots.default is not a function

    究其原因,是因为表格是element-ui通过循环产生的,而vue在dom重新渲染时有一个性能优化机制,就是相同dom会被复用,这就是问题所在,所以,通过key去标识一下当前行是唯一的,不许复用,就行了。

    代码示例如下:

    添加 :key="Math.random()"

    <el-table :data="tableData" style=" 100%;">
       <el-table-column type="selection" width="45"></el-table-column>
       <el-table-column prop="applyTime" label="日期" min-width="150" :key="Math.random()"></el-table-column>
       <el-table-column prop="productName" label="产品名称" min-width="120" :key="Math.random()"></el-table-column>
       <el-table-column prop="orderNo" label="订单号" min-width="120" :key="Math.random()"></el-table-column>
       <el-table-column prop="amount" label="金额" width="150" :key="Math.random()"></el-table-column>
       <el-table-column prop="remark" label="备注" width="150" :key="Math.random()"></el-table-column>
       <el-table-column fixed="right" label="操作" width="200" :key="Math.random()" v-if="currentTab === 'xxx'">
         <template slot-scope="{row}">
           <el-button type="text" size="small">查看详情</el-button>
           <el-button type="text" size="small">编辑</el-button>
         </template>
       </el-table-column>
    </el-table>
  • 相关阅读:
    MFC中的模态对话框与非模态对话框
    汇编学习:float与double速度问题
    汇编学习:二维数组遍历
    SSE练习:单精度浮点数组求和
    StretchDIBits速度测试(HALFTONE)
    StretchDIBits速度测试(COLORONCOLOR)
    多媒体定时器
    typedef与复杂声明
    Image Based Lighting In UE3
    One simple WPF & C# RayTracer
  • 原文地址:https://www.cnblogs.com/hcxy/p/9669588.html
Copyright © 2011-2022 走看看