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