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 ...
随机推荐
- OpenModelica读取文件
parameter String file = Modelica.Utilities.Files.loadResource("J:/git/tcs/tcs.txt"); 将文件名变 ...
- jfinal集成cas单点认证实践
本示例jfinal集成cas单点认证,采用获取到登录用户session信息后,在本地站点备份一份session信息,主要做以下几个步骤: 1.站点引入响应jar包: 2.在web.xml中配置对应过滤 ...
- Linux性能测试工具-UnixBench
■下载路径: unixbench-5.1.2.tar.gz :http://soft.vpser.net/test/unixbench/ unixbench-5.1.3.tar.gz :http:// ...
- Asp.net core 学习笔记 ( Web Api )
asp.net core 把之前的 webapi 和 mvc 做了结合. mvc 既是 api. 但是后呢,又发现, api 确实有独到之处,所以又开了一些补助的方法. namespace Proje ...
- 昂达 v891 v1 终于 删除 windows 分区 并且恢复了容量。
参考了很多文章(最后列出重要的),却始终失败. 途中因为乱改分区表,竟然fastboot 都进不去了,当时真是欲哭无泪. 总结关键点: 1) partition.tbl不能把硬盘剩余空间全给data分 ...
- tchart5
https://blog.csdn.net/wuyuanjingni/article/details/8585810
- maven ----> 子工程中引入父工程
创建父工程,打包方式指定为 pom <groupId>com.example</groupId> <artifactId>SleuthMain</artifa ...
- Django分页器和自定义分页器
一.自定义分页器 import copy class Pagination(): def __init__(self,request,current_page,all_data_num,each_pa ...
- HTML 弹出遮罩层一(遮罩层和内容标签嵌套)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- First Bad Version leetcode java
问题描述: You are a product manager and currently leading a team to develop a new product. Unfortunately ...