vue实现删除用户的操作

1.为删除按钮添加点击事件,并编辑事件


<el-button size="small" type="danger" icon="el-icon-delete" round @click="removeGoods( scope.row.goods_id )"  ></el-button>


// 删除分类按钮 单击   

async removeGoods (id) {     

console.log(id)     

this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {          confirmButtonText: '确定',         

cancelButtonText: '取消',         

type: 'warning'       

}).then(async() => {           

const {data,meta}=await this.$http.delete('goods/'+id)            console.log(meta)           

if(meta.status!==200){               

return this.$message.error(meta.status)         

  }           

this.$message.success(meta.status)           

this.getGoods()       

}).catch(() => {         

this.$message({           

type: 'info',           

message: '已取消删除'         

});                 

});   

},


2.引入消息弹框组件

import { MessageBox } from 'element-ui'

// 在Vue原型对象上挂载消息弹框组件,每个vue组件都可以通过this访问到

Vue.prototype.$confirm = MessageBox.confirm


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容