网站策划的工作要求,网站首页权重低,建网站多少钱一平方,深圳网站建设方维网络前排提示#xff0c;本文为引流文#xff0c;文章内容不全#xff0c;更多信息前往#xff1a;oldmoon.top 查看 简介
使用强大的Vuetify开发前端页面#xff0c;结果发现官方没有提供简便的全局消息通知组件#xff08;像Element中的ElMessage那样#xff09;#xf… 前排提示本文为引流文文章内容不全更多信息前往oldmoon.top 查看 简介
使用强大的Vuetify开发前端页面结果发现官方没有提供简便的全局消息通知组件像Element中的ElMessage那样所以自己动手写了一个简单的组件效果如下 PS如果是我没找到官方版本请评论告诉我下面直接上代码 组件封装
全局变量alert.ts
该文件可视为util文件但我将其放在了stores文件夹下主要提供了两个作用
定义newAlert全局变量用于临时存储新Alert信息。定义常用的全局方法用于快速创建alert如successAlert、errorAlert等。
import { ref } from vueexport interface AlertInfo {id: string,type: string,message: string
}export const newAlert refAlertInfo({id: alert 0,type: ,message:
})export const alert (type: string, message: string) {newAlert.value.id Math.random().toString()newAlert.value.type typenewAlert.value.message message
}export const errorAlert (message: string) {alert(error, message)
}export const successAlert (message: string) {alert(success, message)
}export const infoAlert (message: string) {alert(info, message)
}export const warningAlert (message: string) {alert(warning, message)
}
更多信息前往oldmoon.top 查看