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遍历


基础教程推荐
猜你喜欢
- Ajax验证用户的唯一性 2022-12-28
- HTML5实现无刷新修改URL的方法 2024-03-09
- 基于Ajax和forms组件实现注册功能的实例代码 2023-02-14
- PHP Cookie学习笔记 2024-03-09
- CSS haslayout 彻底了解 2024-01-23
- 全面了解JavaScirpt 的垃圾(garbage collection)回收机制 2024-01-08
- 用JS实现选项卡 2023-12-28
- node.js实现带进度条的多文件上传 2023-12-19
- css overflow溢出隐藏(文字溢出时的自动隐藏处理) 2024-02-06
- css实现左侧固定右侧自适应的布局方式 2024-01-24