文章来源:网络作者:浅殇发布时间:2026-05-23 03:59:32
这篇文章是教大家如何使用微信小程序的提示框?教程简单易学,有需要的小伙伴就赶紧和小编一起来学习一下吧。
比较简单 直接上码

Toast框
提示框
成功提示
取消提示
禁止提示
文本提示
复制代码
js
const App = getApp()
Page({
data: {},
onLoad() {
this.$wuxToast = App.wux(this).$wuxToast
},
showToast() {
const _this =this;
_this.$wuxToast.show({
type: \'success\',
timer: 1500,
color: \'#fff\',
text: \'已完成\',
// 成功之后的返回,想当于下面的success
success: () => console.log(\'已完成\')
// success: function(){
// console.log(\'已完成\')
// }
})
},
showToastCancel() {
const _this =this;
_this.$wuxToast.show({
type: \'cancel\',
timer: 1500,
color: \'#fff\',
text: \'取消操作\',
success: () => console.log(\'取消操作\')
})
},
showToastErr() {
const _this =this;
_this.$wuxToast.show({
type: \'forbidden\',
timer: 1500,
color: \'#fff\',
text: \'禁止操作\',
success: () => console.log(\'禁止操作\')
})
},
showToastText() {
const _this =this;
_this.$wuxToast.show({
type: \'text\',
timer: 1500,
color: \'#fff\',
text: \'文本内容\',
success: () => console.log(\'文本内容\')
})
},
})
复制代码
注意点
在app.js中要引入wxui
import wux from \'components/wux\'
App({
onLaunch() {
console.log(\'onLaunch\')
},
onShow() {
console.log(\'onShow\')
},
onHide() {
console.log(\'onHide\')
},
// 通过scope来引入wux函数
wux: (scope) => new wux(scope)
})
复制代码
以上就是如何使用微信小程序的提示框的全部内容了,大家都学会了吗?
上一篇:怎么预览手机酷狗音乐写真?

梦想三国之勇往直前0.1折

炼仙传说0.1折
仙侠01折
充值享永久0.1折福利,登录每日领2000免费代金券;;

不可思议的刀剑与魔法0.1折
卡牌01折
进游立送真充卡,开局自带“钞能力”

逍遥浪人
卡牌
1折送绝版皮肤 全场充值永久1折,创角即送“黑神话”孙悟空绝版皮肤。

奇幻梦旅人
休闲
当个无忧无虑的旅人,尽情享受这个童话世界吧!

玄影0.1折
仙侠01折
全场充值永享0.1折!

点击冒险之旅(0.1折特级行...
卡牌01折
上线福利:登录即送创角大礼包,召唤顶级战力!

天神赵子龙0.1折
卡牌01折
全新0.1折放置卡牌,打破传统三国叙事,解锁新颖剧情,每日送1000代金;

九州异兽记0.1折
开箱01折
1分钱买SSR异兽

龙魂魔法0.1折
185传奇996传奇
上线即送:自动拾取、自动回收、切割+222、老男孩·称号!

魔药杂货铺什么时候出 公测上线时...