vue中alert toast confirm loading 公用
import Vue
from
'vue'
import { ToastPlugin, AlertPlugin, ConfirmPlugin, LoadingPlugin }
from
'vux'
/*import { Promise } from 'es6-promise';*/
Vue.use(ToastPlugin)
Vue.use(AlertPlugin)
Vue.use(ConfirmPlugin)
Vue.use(LoadingPlugin)
const Message = {};
Message.install = () => {
const msg = {
$toast: config => {
let def = {
type:
'text'
,
text:
''
}
if(typeof config ===
'string'
|| typeof config ===
'number'
){
Vue.$vux.toast.show({type:
'text'
,text:config})
}
else
{
Vue.$vux.toast.show(Object.assign(def,config))
}
},
$alert: config => {
let def = {
title:
'提示'
,
content:
'系统异常,请重新登录后再试!'
,
buttonText:
'确定'
}
if(typeof config ===
'string'
|| typeof config ===
'number'
){
Vue.$vux.alert.show(Object.assign(def,{content:config}));
}
else
{
Vue.$vux.alert.show(Object.assign(def,config));
}
},
$confirm: config => {
let isConfirm =
false
;
let def = {
title:
'提示'
,
content:
'系统异常,请重新登录后再试!'
,
confirmText:
'确定'
,
cancelText:
'取消'
,
onConfirm:() =>{
isConfirm =
true
;
}
}
if(typeof config ===
'string'
|| typeof config ===
'number'
){
Vue.$vux.confirm.show(Object.assign(def,{content:config}));
}
else
{
Vue.$vux.confirm.show(Object.assign(def,config));
}
/*return new Promise((resolve,reject) => {
if(isConfirm){
resolve();
}
})*/
},
$showLoading: config => {
let def = {
text:
'加载中...'
}
if(typeof config ===
'string'
|| typeof config ===
'number'
){
Vue.$vux.loading.show(Object.assign(def,{text:config}));
}
else
{
Vue.$vux.loading.show(Object.assign(def,config));
}
}
}
Object.entries(msg).forEach(([method,fn]) => {
Vue.prototype[method] = fn;
})
}
Vue.use(Message)
vue中alert toast confirm loading 公用的更多相关文章
- 去掉网页中alert和confirm弹出框自带的网址
去掉网页中alert和confirm弹出框自带的网址 Alert: <script> window.alert = function(name){ var iframe = documen ...
- vue 中使用 Toast弹框
import { ToastPlugin,ConfirmPlugin,AlertPlugin} from 'vux' Vue.use(ToastPlugin) Vue.use(ConfirmPlugi ...
- Vue自定义全局Toast和Loading
如果我们的Vue项目中没有用到任何UI框架的话,为了更好的用户体验,肯定会用到loading和toast.那么我们就自定义这两个组件吧. 1.Toast组件 首先,在common下新建global文件 ...
- Vue 中使用 extent 开发loading等全局 组件
Vue 中使用 extend 开发组件 简介:再开发过程中那面会遇到自定义 loading alert 等全局组件,这里我们可以使用 vue 中的extend 来帮助我们完成 一个简单extend例子 ...
- vue中的toast组件
首先在components新建组件文件夹 随后在toast.vue中写入弹框样式 <template> <transition name="demo"> & ...
- vue中自定义组件(插件)
vue中自定义组件(插件) 原创 2017年01月04日 22:46:43 标签: 插件 在vue项目中,可以自定义组件像vue-resource一样使用Vue.use()方法来使用,具体实现方法: ...
- Ionic4.x Javascript 扩展 ActionSheet Alert Toast Loading 以及 ionic 手势相 关事件
1.ActionSheet 官方文档:https://ionicframework.com/docs/api/action-sheet <ion-header> <ion-toolb ...
- Bootstrap Modal 框 alert confirm loading
/** * Created by Administrator on 2016/5/4. */ /** * 模态窗口 */ window.Modal = { tpls:{ alert:'<div ...
- Android线程中使用Toast、dialog、loading
代码改变世界 Android线程中使用Toast.dialog.loading Loading: Thread t1 = new Thread(new Runnable() { @Override p ...
随机推荐
- class与struct的区别
C++中的struct对C中的struct进行了扩充,它已经不再只是一个包含不同数据类型的数据结构了,它已经获取了太多的功能: ①struct能包含成员函数吗? 能! ②struct能继承吗? 能!! ...
- phantomjs 下载
http://phantomjs.org/download.html
- Django中ORM简介与单表数据操作
一. ORM简介 概念:.ORM框架是用于实现面向对象编程语言种不同类型系统的数据之间的转换 构建模型的步骤:重点 (1).配置目标数据库信息,在seting.py中设置数据库信息 DATABASE ...
- Java SE HashMap的底层实现
1.hash散列算法 由于hashmap在存储过程中是数组加链表的存储过程,所以定义数组长度为16(建议是2的n次幂的长度),之后进行每个数组的地址都指向一个链表进行存储 hash表算法可对数组长度l ...
- 学习笔记29—Linux基础
一.简单命令: 1.进入文件夹heyi目录:cd ./heyi 2.查看该目录下内容:ls 二.linux压缩和解压缩命令大全 tar命令 解包:tar zxvf FileName.tar 打包:ta ...
- lambda表达式与方法重载问题
笔者之前在学习Java8新特性的时候,最吸引我的就是lambda表达式,它无疑为Java函数编程提供了强有力的支持.lambda表达式的使用方法很简单,下面给出最简单的用法. // Interface ...
- Axure 动态面板的状态与尺寸
知识点: 1.动态面板的状态下相当动态面版的模式,当符合某种条件的话就选择对应的动态面板的状态 2.动态面板的尺寸可以根据内容自动调整大小 本节教程主要分为一下图片两种场景: 出现动态面板中的两种.一 ...
- CF1117E Decypher the String
如果我们能询问一个排列的话,我们就可以得到这个置换,然后反向求解. 但现在字符集只有26. 考虑26^3>1e5. 用一个三维坐标去映射到一个一维整数,然后就可以构造排列了. #include& ...
- Prime Ring Problem HDU - 1016
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle ...
- Selenium-WebDriverApi接口详解
浏览器操作 # 刷新 driver.refresh() # 前进 driver.forward() # 后退 driver.back() 获取标签元素 # 通过ID定位目标元素 driver.find ...