Files
zhxg_pc/src/utils/toast.js

48 lines
963 B
JavaScript
Raw Normal View History

2025-08-14 15:43:24 +08:00
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')
}