element 的Notification 通知二次封装

element 的Notification 通知二次封装
每次需要提示时都会些下面这段代码,导致每次引用不是很方便。

this.$notify({
    
    
          title: '成功',
          message: '这是一条成功的提示消息',
          type: 'success'
        });

所以我将其封装成js。

import {
    
     Notification } from 'element-ui';



/**
 *@functionName: 通知的封装(成功和警告)
 *@params1: title
 *@params2: message
 *@params3: type  enum[success,warning]
 *@description:
 *@author: yk 
 *@date: 2023-11-30 10:18:58
 *@version: V1.0.0
 */

export function successNotification(title, message, type) {
    
    
    if (type == null || type == undefined || type == "") {
    
    
        type = "success"
    }
    Notification({
    
    
        title: title,
        message: message,
        type: type,
        position: 'bottom-right'
    });
}

/**
 *@functionName: 通知的封装(错误)
 *@params1: title
 *@params2: message
 *@description:
 *@author: yk 
 *@date: 2023-11-30 10:18:58
 *@version: V1.0.0
 */
export function errNotification(title, message) {
    
    
    Notification.error({
    
    
        title: title,
        message: message,
        position: 'bottom-right'
    });
}

/**
 *@functionName: 通知的封装(消息)
 *@params1: title
 *@params2: message
 *@description:
 *@author: yk 
 *@date: 2023-11-30 10:18:58
 *@version: V1.0.0
 */
export function infoNotification(title, message) {
    
    
    Notification.info({
    
    
        title: title,
        message: message,
        position: 'bottom-right'
    });
}

引入js文件

import {
    
    
        successNotification,
        errNotification,
        infoNotification
    } from "./utils/el-ementui"

调用

successNotification("成功", "删除成功", "success");
                    //errNotification("失败", "删除失败")
                    //infoNotification("提示", "没有权限")

完成!!!!!

猜你喜欢

转载自blog.csdn.net/weixin_45384466/article/details/134706768