m0_60100666 2022-08-31 10:21 采纳率: 25%
浏览 69
已结题

element UI 动态渲染表格,其中有一列表头带有点号,无法渲染数据出来,其他的列都能渲染,

element UI 动态渲染表格,其中有一列表头带有点号,无法渲染数据出来,其他的列都能渲染,
打印数据也已经拿到,就是不渲染

<el-table-column
:label="item"
v-for="(item,index) in tableDataFields"
show-overflow-tooltip
width="180px"
:prop="item"
:key="index"
:fixed="index == 0"
:column-key="index+''"

    >
      <template slot="header" slot-scope="scope">
        <div 
          :title="scope.column.label"
          :class="{'lightCol':curColIndex==index+''}"
        >{{scope.column.label}}</div>
      </template>
    </el-table-column>
尝试了其他*,/都能渲染出来,是什么原因导致的
  • 写回答

2条回答 默认 最新

  • Z_pigeon 2022-08-31 11:06
    关注

    大为震惊,我竟然能模拟出你数据,并为之震撼

    第一步:添加多一个插槽

    img


    第二步,定义方法

    img


    完整页面代码如下
    <template>
        <el-table :data="tableData" style="width: 100%">
            <el-table-column
                :label="item"
                v-for="(item,index) in tableDataFields"
                show-overflow-tooltip
                width="180px"
                :prop="item"
                :key="index"
                :fixed="index == 0"
                :column-key="index+''">
                <template slot="header" slot-scope="scope">
                    <div  :title="scope.column.label">{{scope.column.label}}</div>
                </template>
                <template slot-scope="scope">
                    <div  :title="scope.column.label">{{getData(scope, item)}}</div>
                </template>
            </el-table-column>
        </el-table>
    </template>
    
    <script>
    export default {
        data() {
            return {
                tableDataFields: [ '日.期', '姓名', '地址' ],
                tableData: [
                    {
                        '日.期': "2016-05-02",
                        '姓名': "王小虎",
                        '地址': "上海市普陀区金沙江路 1518 弄",
                    },
                    {
                        '日.期': "2016-05-04",
                        '姓名': "王小虎",
                        '地址': "上海市普陀区金沙江路 1517 弄",
                    },
                    {
                        '日.期': "2016-05-01",
                        '姓名': "王小虎",
                        '地址': "上海市普陀区金沙江路 1519 弄",
                    }
                ],
            };
        },
        methods: {
            getData (scope, item) {
                return scope.row[item]
            },
        },
    };
    </script>
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月28日
  • 已采纳回答 9月20日
  • 创建了问题 8月31日

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么