iview表格简单二次封装

该博客介绍了如何在Vue.js中使用Table组件,展示数据并自定义列模板。通过`v-for`指令遍历`columns`和`dataSource`,并在每个列上应用自定义插槽来实现内容的个性化展示。示例代码展示了如何传递属性和使用内联模板进行数据绑定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<template>
    <Table ref="current" v-bind="$attrs" :columns="columns" :data="dataSource">
        <template v-for="item in columns" :slot="item.slot?item.slot:''" slot-scope="{ row, column , index }">
            <slot :name="item.slot?item.slot:''" v-bind="{ row, column , index }"></slot>
        </template>
    </Table>
</template>
<script>
export default {
    props: {
        columns: {
            type: Array,
            default () {
                return []
            }
        },
        dataSource: {
            type: Array,
            default () {
                return []
            }
        }
    }
}
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值