【vue】avue-crud解决单元格点击事件传递行点击事件

news/2024/7/9 23:48:23 标签: vue

1.问题示例图

1.点击单元格事件时,同时触发了行点击事件
在这里插入图片描述

2.代码示例

1.在单元格点击事件上加.stop,防止事件传递

<template>
  <avue-crud ref="crud" :option="option" @row-click="rowClick" :data="data" >
    <template slot-scope="scope" slot="age">
      <div>
        <el-link @click.stop="cellClick">{{ scope.row.age }}</el-link>
      </div>
    </template>
  </avue-crud>
</template>

<script>

export default {
  name: 'demo.vue',
  data() {
    return {
      drawer: false,
      nodes: [],
      openId: [],
      openTitle: '',
      openData: {},
      data: [
        {
          id: 0,
          name: '张三',
          age: '12'
        },
        {
          id: 1,
          name: '李四',
          age: '23'
        }
      ],
      option: {
        menu: false,
        delBtn: false,
        addBtn: false,
        editBtn: false,
        addRowBtn: true,
        cellBtn: false,
        cancelBtn: false,
        column: [
          {
            label: '姓名',
            prop: 'name',
            cell: true
          },
          {
            label: '年龄',
            prop: 'age',
            cell: true
          }
        ]
      }
    }
  },
  methods: {
    rowClick(row, column, event) {
      alert('行点击事件')
    },
    cellClick(row, column, cell, event) {
      alert('单元格点击事件')
    }
  }
}
</script>

3.结果示例图

在这里插入图片描述


http://www.niftyadmin.cn/n/903300.html

相关文章

【电脑系统】window系统查询端口号占用

1.查询指定端口号 //查询端口号为8080的进程 netstat -anof |findstr 88882.杀死进程 //杀死对应的pid为16044的进程 taskkill /pid 16044 -t -f

【java】自定义校验Bean数字只能为1和5

1.校验状态接口 package com.test;import com.test.ValidStatusValidator; import javax.validation.Constraint; import javax.validation.Payload; import javax.validation.constraints.NotNull; import java.lang.annotation.*;import static java.lang.annotation.Elemen…

【css】文字过长的部分显示为点点点

1.div white-space: nowrap; overflow: hidden; text-overflow: ellipsis;2.span display:inline-block; white-space: nowrap; width:170px; overflow: hidden; text-overflow: ellipsis;

【java】Aspect切面示例

1.注解 package com.test.annotation;import java.lang.annotation.*;Documented Target(ElementType.METHOD) Retention(RetentionPolicy.RUNTIME) public interface UpdateStudentAnnotation {String value() default ""; }2.切面 package com.test;import com.t…

【linux】防火墙命令

1.查看防火墙 //1.centos 6查看防火墙 service iptables status //2.centos 7查看防火墙 firewall -cmd --state2.关闭防火墙 //1.centos 6关闭防火墙 service iptables stop //2.centos 7关闭防火墙 //查看状态 systemctl status firewalld.service //关闭 systemctl stop f…

【js】日期格式化

代码示例 export function dateFormat(date, format) {format format || yyyy-MM-dd hh:mm:ss;if (date ! Invalid Date) {let o {"M": date.getMonth() 1, //month"d": date.getDate(), //day"h": date.getHours(), //hour"m": d…

【vue】el-date-picker默认时间

1.代码示例 <template><el-date-picker suffix-icon"el-icon-date" range-separator"-" type"daterange" placeholder"选择日期" v-model"dateBucket" format"yyyy-MM-dd"value-format"yyyy-MM-d…

【maven】将本地jar放入本地maven仓库

1.命令 //将c盘目录C:\Users\User\Downloads中的test-1.0-20210617.014010-39.jar包放入本地maven仓库&#xff0c;其中groupId为com.test&#xff0c;artifactId为test&#xff0c;版本号为1.0-SNAPSHOT mvn install:install-file -DfileC:\Users\User\Downloads\test-1.0-20…