1.為刪除按鈕添加點(diǎn)擊事件,并編輯事件
<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('此操作將永久刪除該文件, 是否繼續(xù)?', '提示', {? ? ? ? ? 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