wx.showToast中的一个问题
wx.showToast({
title: '成功',
icon: 'fail',
duration: 2000,
success: func
})
wx.showToast({
title: '成功',
icon: 'fail',
duration: 2000,
success: res => {
func()
}
})
使用以上两种语句都会“马上”执行func
, WHY?
因为只要成功弹出了窗口就会调用success, 所以如果要在duration
毫秒后执行func
, 代码如下:
wx.showToast({
title: '成功',
icon: 'fail',
duration: 2000,
})
setTimeout(func, 2000)