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 ...
随机推荐
- mysql利用navicat导出表结构和表中数据
LZ在网上搜索了要如何导出mysql的表结构和表中数据,发现有的方法不好用 记录一下好用的方式: 用navicat打开DB链接后,点击数据库,右击选择转储SQL文件,然后选择结构和数据: 之后弹出新的 ...
- Python 列表list 字典dict
# coding=utf-8 支持中文 # 列表 n1 = [1, 2, 3] print n1 print len(n1) n1.append(4) print n1 # 字典,包含键值 dic = ...
- 《剑指offer》第六十七题(把字符串转换成整数)
// 面试题67:把字符串转换成整数 // 题目:请你写一个函数StrToInt,实现把字符串转换成整数这个功能.当然,不 // 能使用atoi或者其他类似的库函数. #include <ios ...
- 第 6 章 存储 - 044 - volume 生命周期管理
volume 生命周期管理 1)备份 因为 volume 实际上是 host 文件系统中的目录和文件,所以 volume 的备份实际上是对文件系统的备份 例如:本地的Registry,所有镜像都存在/ ...
- Java定时器的三种实现方式
一.普通thread /** * 普通thread * 这是最常见的,创建一个thread,然后让它在while循环里一直运行着, * 通过sleep方法来达到定时任务的效果.这样可以快速简单的实现, ...
- Shell脚本中的并发(转)
转自http://blog.csdn.net/wangtaoking1/article/details/9838571 主要记录一下Shell脚本中的命令的并发和串行执行. 默认的情况下,Shell脚 ...
- C# wave mp3 播放器探寻
C# wave mp3 播放器探寻 最近无聊,想听听歌曲.可怜新电脑上歌曲就两三首,要听其它的就得在旧电脑上播放.可是,那台古董但不失健壮的本本被老婆无情的霸占了.无奈. 思来想去,得,写个程序播 ...
- 7 selenium 模块
selenium 模块 一.简介 1.Python的一个第三方库,对外提供的接口可以操作浏览器,然后让浏览器完成自动化的操作. 2.自动化测试工具,而爬虫中使用它主要是为了解决requests无法直接 ...
- python基础之 025 模块加载与import的使用
内容梗概: 1. 模块 2. import 3. from xxx import xxx 1.模块定义:模块就是一个包含了python定义和声明的文件,文件名就是模块的名字加上.py后缀.目前写的所有 ...
- c 语言连续输入字符型数据
#include<stdio.h> #include<stdlib.h> void Input1(char* &str){ // /* 这种情况下想要逐个输入字符串数组 ...