<el-button type="success" size="small" link @click="openFormB(scope.row)" buttonType="tj">添加++ <el-button type="success" plain @click="openFormB()" buttonType="xz">新增

methods: {
  openFormB(event) {
    const buttonType = event.target.innerText;
    if (buttonType === '新增') {
      console.log('xxxxx是新增嗷呜xxxxx');
    } else if (buttonType === '添加') {
      console.log('xxxxx是添加嗷呜xxxxx');
    }
  }
}

要获取按钮的名称,可以使用事件对象(event)的target属性来获取点击的按钮元素,然后通过按钮元素的innerText属性获取按钮的文本内容。

Element Plus 按钮名称获取及判断:新增、添加按钮区分

原文地址: https://www.cveoy.top/t/topic/qgOD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录