• element-ui和element-plus的自定义列表格用法


    前言

     element-plus 这个 UI 组件库,虽说基本和 vue2 + element-ui 差不多,但还是有点区别,以至于按emenent-ui的写法来写会发现报错,下面我将讲解一下element-ui和element-plus的自定义表格的用法

    element 中的自定义列表格用法

    自定义列时只需要声明 slot-scope="scope" 即可。自定义内容需要使用数据时只需要使用 scope.row 即可获取该行数据。

    1. <template slot-scope="scope">
    2. <div class="overPointr2">
    3. {{scope.row.address}}
    4. </div>
    5. </template>

    完整的代码:

    1. <el-table
    2. :data="tableData"
    3. style="width: 100%">
    4. <el-table-column
    5. type="index"
    6. width="50">
    7. </el-table-column>
    8. <el-table-column
    9. prop="name"
    10. label="姓名"
    11. min-width="120">
    12. </el-table-column>
    13. <el-table-column
    14. label="地址"
    15. min-width="300">
    16. <template slot-scope="scope">
    17. <div class="overPointr2">
    18. {{scope.row.address}}
    19. </div>
    20. </template>
    21. </el-table-column>
    22. <el-table-column
    23. label="操作"
    24. min-width="120">
    25. <template slot-scope="scope">
    26. <el-button
    27. @click.native.prevent="deleteRow(scope.$index, tableData)"
    28. type="text"
    29. size="small">
    30. 移除
    31. </el-button>
    32. </template>
    33. </el-table-column>
    34. </el-table>

    element-plus 中的自定义列表格用法

    跟 element 差不多,只不过不再是声明 slot-scope="scope",而是按需声明 #default 或者 #default="scope"

    • 自定义内容需要使用该行数据时,声明 #default="scope",再通过 scpoe.row 获取数据。
    1. <el-table-column
    2. fixed="right"
    3. label="操作"
    4. width="100">
    5. <template #default="scope">
    6. <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
    7. <el-button type="text" size="small">编辑</el-button>
    8. </template>
    9. </el-table-column>
    • 自定义内容需要使用该行数据时,声明 v-slot:default="scope",再通过 scpoe.row 获取数据。
    1. <el-table-column label="操作" align="center">
    2. <template v-if="true" v-slot:default="scope">
    3. <el-button type="primary" size="small" @click="bj"><el-icon><Edit /></el-icon> <span style="margin-left: 3px">编辑</span></el-button>
    4. <el-button type="danger" size="small" @click="sc(scope.row)"><el-icon><Delete /></el-icon> <span style="margin-left: 3px">删除</span></el-button>
    5. </template>
    6. </el-table-column>

  • 相关阅读:
    arthas-线上排查问题工具
    15 医疗挂号系统_【预约挂号】
    nodejs基于Vue.js健身体育器材用品商城购物网97794
    图像识别(九)| 彻底搞懂SoftMax分类的底层逻辑
    Markdown 数学公式详解
    读书郎通过上市聆讯:平板业务毛利率走低,2021年利润同比下滑11%
    代码随想录day48|转行当小偷咯|打家劫舍系列|Golang
    穿山甲广告位生效时间,广告位不合法,广告位错误等
    flink 8081 web页面无法被局域网内其他机器访问
    [Power Query] 数据的透视与逆透视
  • 原文地址:https://blog.csdn.net/m0_55333789/article/details/132888272