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遍历
基础教程推荐
猜你喜欢
- 网页设计中的CSS Sprites技术介绍及其优化方法 2024-01-08
- 关于 html:CSS – 调整浏览器窗口大小时修复边 2022-09-21
- 「HTML+CSS」--自定义加载动画【022】 2023-10-26
- Easyui form combobox省市区三级联动 2023-12-15
- servlet+html+mysql实现登录注册功能 2023-10-25
- vue滚动固定顶部及修改样式的实例代码 2024-01-17
- ajax实现省市三级联动效果 2023-02-22
- 解决CSS中子元素z-index与父元素兄弟节点的层级问题 2023-12-19
- 关于ES6中的箭头函数超详细梳理 2022-08-30
- 利用jquery禁止外层滚动条的滚动 2024-01-17
