handleDelete: function (row) {
this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', '系统提示', {
confirmButtonText: "确定",//必填
cancelButtonText: "取消",//必填
type: "warning",//必填
beforeClose: async (action, instance, done) => {
if (action === "confirm") {
instance.confirmButtonLoading = true;
instance.confirmButtonText = "执行中...";
await delMenu(row.id).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {})
}
instance.confirmButtonLoading = false;
done();
},
}).catch(() => {})
}
请问一下各位,这段代码怎么封装起来呀?
封装个 方法 。全局 导入 就行。 然后 就可以 用 this.$handleDelete
// handleDelete.js
import { MessageBox, Message } from "element-ui";
export default function handleDelete() {}
// index.js
import kyHandleDelete from "./handleDelete";
export { kyHandleDelete }
// 使用
import { kyHandleDelete } from "../hooks/index.js";