# 普通用法

点击查看代码
<template>
  <div>
    <ygp-crud
      :data="data"
      :option="option"
      @row-edit="rowEdit"
      @row-del="rowDel"
      @row-view="rowView"
    ></ygp-crud>
  </div>
</template>
export default {
  data() {
    return {
      data: [
        {
          name: "张三",
          sex: "男",
          date: "1994-02-23 00:00:00",
        },
        {
          name: "李四",
          sex: "女",
          date: "1994-02-23 00:00:00",
        },
        {
          name: "王五",
          sex: "女",
          date: "1994-02-23 00:00:00",
        },
        {
          name: "赵六",
          sex: "男",
          date: "1994-02-23 00:00:00",
        },
      ],
      option: {
        menu: true,
        editBtn: true,
        delBtn: true,
        viewBtn: true,
        columns: [
          {
            label: "姓名",
            prop: "name",
            fixed: "left",
            width: 180,
          },
          {
            label: "性别",
            prop: "sex",
            width: 300,
          },
          {
            label: "日期",
            prop: "date",
            width: 300,
          },
        ],
      },
    };
  },
  methods: {
    rowEdit(form, index) {
      this.$message.success("编辑数据" + JSON.stringify(form));
    },
    rowDel(form, index) {
      this.$message.error("删除数据" + JSON.stringify(form));
    },
    rowView(form, index) {
      this.$message.success("查看数据" + JSON.stringify(form));
    },
  },
};