【vue】avue-crud行编辑

导读:本篇文章讲解 【vue】avue-crud行编辑,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

【vue】avue-crud行编辑

1.vue页面代码

<template>
  <avue-crud ref="crud" :option="option" :data="data" @row-update="rowUpdate">
    <template slot-scope="{row,index}" slot="menu">
      <el-button type="primary" icon="el-icon-edit" size="small" v-if="!row.$cellEdit" @click="rowCell(row,index)" circle></el-button>
      <el-button type="success" icon="el-icon-check" size="small" v-else @click="rowCell(row,index)" circle></el-button>
      <el-button type="warning" icon="el-icon-close" size="small" v-if="row.$cellEdit" @click="rowCancel(row,index)" circle></el-button>
    </template>
  </avue-crud>
</template>

<script>

export default {
  name: 'demo.vue',
  data() {
    return {
      drawer: false,
      nodes: [],
      openId: [],
      openTitle: '',
      openData: {},
      data: [
        {
          id: 0,
          name: '张三'
        },
        {
          id: 1,
          name: '李四'
        }
      ],
      option: {
        delBtn: false,
        addBtn: false,
        editBtn: false,
        addRowBtn: true,
        cellBtn: false,
        cancelBtn: false,
        column: [
          {
            label: '姓名',
            prop: 'name',
            cell: true,
            rules: [
              {
                required: true,
                message: '请输入姓名',
                trigger: 'blur'
              }
            ]
          }
        ]
      }
    }
  },
  methods: {
    rowCell(row, index) {
      this.$refs.crud.rowCell(row, index)
    },
    rowCancel(row, index) {
      this.$refs.crud.rowCancel(row, index)
    },
    rowUpdate(form, index, done) {
      // 更新操作
      this.$message.success(
        '编辑数据' + JSON.stringify(form) + '数据序号' + index
      )
      done()
    }
  }
}
</script>

2.示例图片

在这里插入图片描述
链接: https://www.avuejs.com/doc/crud/crud-cell.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/92444.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!