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)
posted @ 2024-09-08 20:17  GoodCoder666  阅读(5)  评论(0编辑  收藏  举报