Files
zhxg_pc/src/utils/toast.js
2025-08-14 15:43:24 +08:00

48 lines
963 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Message } from 'element-ui'
/**
* 显示Toast消息
* @param {string} message - 消息内容
* @param {string} type - 消息类型: 'success', 'warning', 'info', 'error'
* @param {number} duration - 显示时长默认3000ms
*/
export function showToast(message, type = 'info', duration = 3000) {
Message({
message,
type,
duration,
showClose: true
})
}
/**
* 显示成功消息
* @param {string} message - 消息内容
*/
export function showSuccess(message) {
showToast(message, 'success')
}
/**
* 显示错误消息
* @param {string} message - 消息内容
*/
export function showError(message) {
showToast(message, 'error')
}
/**
* 显示警告消息
* @param {string} message - 消息内容
*/
export function showWarning(message) {
showToast(message, 'warning')
}
/**
* 显示信息消息
* @param {string} message - 消息内容
*/
export function showInfo(message) {
showToast(message, 'info')
}