朱丽叶

导航

element-plus消息提示的封装

import { ElMessage } from "element-plus";
import type { EpPropMergeType } from "element-plus/es/utils/vue/props/types";
/**
 *
 * @param msg 提示的内容
 * @param type 提示的类型
 */
function showToast(
  msg: string,
  type: EpPropMergeType<
    StringConstructor,
    "success" | "warning" | "info" | "error",
    unknown
  >
) {
  ElMessage({
    message: msg,
    type,
  });
}

function success(msg: string) {
  showToast(msg, "success");
}
function warning(msg: string) {
  showToast(msg, "warning");
}
function info(msg: string) {
  showToast(msg, "info");
}
function error(msg: string) {
  showToast(msg, "error");
}

export { showToast, success, warning, info, error };


// 使用
import { success } from "@/utils/element-util"
success("登陆成功!")

posted on 2022-09-13 22:38  朱丽叶  阅读(1787)  评论(0)    收藏  举报