1.首先引入
import { Toast } from 'vant'
写个小列子
绑定一个click事件
2.写事件
在methods写方法
showToast() { this.$toast({ message: "今日签到+3", }) },
3.效果图如下
一个简单的toast提示成就好了
下面通过实例代码看下vue 中使用 Toast弹框
import { ToastPlugin,ConfirmPlugin,AlertPlugin} from 'vux' Vue.use(ToastPlugin) Vue.use(ConfirmPlugin) Vue.use(AlertPlugin) //公用的弹窗(全局变量) Vue.prototype.showToast = function( showPositionValue,type,text,width="10em"){ this.$vux.toast.show({ showPositionValue: false, text: text, type: type, width: width, position: 'middle' }) } //公用alert confirm const Message = {}; Message.install = () => { const msg = { 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(); } })*/ }, } Object.entries(msg).forEach(([method,fn]) => { Vue.prototype[method] = fn; }) } Vue.use(Message) //使用例子 _this.confirm({ title:'提示', content: '确定要关闭订单', onConfirm() { console.log('取消订单了'); } });
总结
以上所述是小编给大家介绍的vue.js中toast用法及使用toast弹框的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月27日
2024年09月27日
- 纯音入心系列纯音乐《中央民族乐团-古筝传奇》1CD[MP3][253.1MB]
- 江玲.1989-这样你才爱我,是吗?【新作有声】【WAV+CUE】
- 郭美美.2010-我是郭美美【华纳】【WAV+CUE】
- 黄心懋1991-轻忧郁【滚石】【WAV+CUE】
- 群星.2000-大地金曲世纪回顾2CD【大地】【WAV+CUE】
- 王菲.1996-浮躁(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 群星.2022-传家电视剧原声带【东阳欢娱】【FLAC分轨】
- 《摇滚教父 伍佰黄金精选 2CD》 [WAV+CUE][1GB]
- 《凤凰传奇 我从草原来》[WAV/分轨][400MB]
- 《叶倩文 真心真意过一生》[WAV+CUE][400MB]
- 潘越云.1985-世间女子(滚石25周年经典复刻版)【滚石】【WAV+CUE】
- 陈柏宇.2009-CANT.BE.HALF【SONY】【WAV+CUE】
- 李明依.1989-小女生【滚石】【WAV+CUE】
- 《李荣浩 新时代创作新人王》[WAV分轨][310MB]
- 《黑鸭子与马头琴 史上最动听草原音乐》[WAV+CUE][320MB]