1. 表示操作成功,文字上方会显示一个表示操作成功的图标。
wx.showToast({
title: '操作成功!', // 标题
icon: 'success', // 图标类型,默认success
duration: 1500 // 提示窗停留时间,默认1500ms
})
2.表示加载中,显示为加载中图标。
wx.showToast({
title: '加载中...',
icon: 'loading',
duration: 1500
})
3.不显示图标,一般用作提示。
wx.showToast({
title: '该功能未上线!',
icon: 'none',
duration: 1500
})
以上3种弹窗均使用wx.showToast接口,调用后会根据设定的duration停留一定时间。
此外,表示加载中的弹窗还可以使用wx.showLoading接口,但调用该接口时弹窗并不会自动消失,而是需要手动调用wx.hideLoading接口使弹窗消失。
// 开始加载数据
wx.showLoading({
title: '加载中',
})
// 数据加载中...
// 数据加载中...
// 数据加载完成,隐藏弹窗
wx.hideLoading()
// 或 设置定时器来隐藏弹框
setTimeout(function(){
wx.hideToast()
},2000)
还有一个 可以点击“确定”,也可以点击“取消的”弹出框
wx.showModal({
title: '提示',
content: '这是一个模态窗口',
success:function(res){
if(res.confirm){
console.log('弹框后点取消')
}else{
console.log('弹框后点取消')
}
}
})
如果此文对你有帮助请点赞或者打赏哦 ^-^