1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| import { MessageBox, Message } from "element-ui";
export function handleConfirm(text = "确定执行此操作吗?", type = "danger") { return MessageBox.confirm(text, "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: type, center: true }); }
export function handleAlert(text = "操作成功", type = "success") { return Message({ showClose: true, message: text, type: type }); } #页面vue文件中引用
import { handleConfirm, handleAlert } from '@/utils/confirm' export default { data() { return { ... }; }, methods: { ... handleClose(formName) { handleConfirm('系统将不会保存您所做的更改,确定要离开吗?').then(res => { ... }).catch(err => { console.log('err', err) }) }, delConfirm(formName) { ... handleAlert('删除成功') ... } }, ... }
|