
vue项目如何利用v-for批量绑定按钮,下面给大家简单介绍一下实现代码!
1、定义一个v-for循环
<el-button v-for="(item, index) in tableBtn" :type="item.type" :icon="item.icon" :key="index" @click="callBack(item.method)"> { item.label }} </el-button>
2、tableBtn数组
_table.tableBtn = [
  {
    type: "primary",
    icon: "el-icon-picture-outline",
    method: "openImage",
    label: "图像"
  },
  {
    type: "primary",
    icon: "el-icon-document",
    method: "openReport",
    label: "报告"
  },
  {
    type: "danger",
    icon: "el-icon-video-camera",
    method: "openVideo",
    label: "视频"
  }
];
3、methods按钮事件
openImage() {
  console.log("打开图像");
},
openReport() {
  console.log("打开报告";
},
openVideo() {
  console.log("打开视频");
},
callBack(method) {
  this[method]();
}
v-for循环绑定el-color-picker颜色选择器绑定value/v-model值
上面是“vue项目利用v-for批量绑定按钮”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2941.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

 dedecms {dede:datalist}标签下,if语句的运用!{dede:
 dedecms {dede:datalist}标签下,if语句的运用!{dede: