几种常见的弹框提示信息
第一种模态窗口:
wx.showModal
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
wx.showModal({
title: '提示',
content: '这是一个模态窗口',
success:function(res){
if(res.confirm){
console.log('弹框后点取消')
}else{
console.log('弹框后点取消')
}
}
})
},
第二种提示你想提示的信息。不带确定和取消按钮。可以用在判断注册成功或失败的验证。
wx.showToast
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
wx.showToast({
title:'成功',
icon:'success',
duration:2000
})
},
第二种弹框的时候如果icon:none只是提示title里的文字不会有样式的弹框显示。
隐藏消息提示框
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.showToast({
title: '加载中',
icon:'loading',
duration:10000
})
setTimeout(function(){
wx.hideToast()
},2000)
},
关闭当前页面,跳转到应用内的某个页面。
wx.redirectTo(OBJECT)
wx.redirectTo({
url: '../index/index',
})