html代码
<template slot-scope="scope">
<el-button
v-for="(item, index) in tableBtn"
:key="index"
size="mini"
:type="item.type"
@click="tabFun(item, scope.row)"
>{{ item.name }}</el-button >
</template>
2、js
//data
tableBtn: [{
type: "primary",
icon: "el-icon-document",
click: "handleReport",
name: "报告"
},
{
type: "success",
icon: "el-icon-picture-outline",
click: "handleImage",
name: "图像"
}, {
type: "primary",
icon: "el-icon-plus",
click: "handleAdd",
name: "新增"
},
{
type: "danger",
icon: "el-icon-delete",
click: "handleDelete",
name: "删除"
}],
//methods
tabFun(btn, row) {
if (this[btn.click]) {
this[btn.click](btn, row);
} else {
console.log("方法未定义!");
}
},
//报告事件
handleReport(index, row) {
console.log("handleReport");
},
//图像事件
handleImage(index, row) {
console.log("handleImage");
},
//新增事件
handleAdd(index, row) {
console.log("handleAdd");
},
//删除事件
handleDelete(index, row) {
console.log("handleDelete");
}
以上是编程学习网小编为您介绍的“el-button按钮实现v-for遍历”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:el-button按钮实现v-for遍历
猜你喜欢
- vue webpack重写cookie路径的方法 2024-02-29
- 如何优化CSS中的文本大小设置问题 2023-10-08
- jquery实现漂浮在网页右侧的qq在线客服插件示例 2024-01-04
- 在html站点上的Node.js mysql显示表 2023-10-25
- JavaScript数据在不同页面的传递(URL参数获取) 2023-08-11
- 弹窗居中的简单实现方法 2024-02-21
- .NET使用js制作百度搜索下拉提示效果(不是局部刷新)实现思路 2024-01-17
- xWin之JS版(2-26更新) 2024-02-22
- 定义标题的最好方法 2022-10-16
- 基于Jquery.history解决ajax的前进后退问题 2022-10-17