Various pop-up prompts of uniapp WeChat applet (light prompt)

You can copy and paste directly to use without special processing.

If you are satisfied, please give Mo Chengchen a Fabulous
1: Plain text prompt box
uni.showToast({
    
    
	title: '只有文字弹窗',
	icon: 'none',    //如果要纯文本,不要icon,将值设为'none'
	duration: 2000    //持续时间为 2秒
})  
2: Prompt box with success icon
uni.showToast({
    
    
	title: '成功提示弹窗',
	icon: 'success',    //将值设置为 success 或者 ''
	duration: 2000    //持续时间为 2秒
})  
3: Prompt box with cancel confirmation
uni.showModal({
    
    
		title: '有确认取消的弹窗',
		content: '确认要删除该项吗?',
		success: function(res) {
    
    
		if (res.confirm) {
    
    
			console.log('点击了确认')
		} else {
    
    
			console.log('点击了取消')
		}
	}
})
4: With picture prompt box
uni.showToast({
    
    
	title: '自定义图标弹窗',
	//图片优先级更高但您应该使用本地的而非线上的图片链接
	image: '../../static/logo.png',
	duration: 2000     
})
5: The prompt box is loading
//showLoading 需要用hideLoading来结束,一般网络请求封装中常用
uni.showLoading({
    
    
	title:'加载中...'
});
setTimeout(()=>{
    
    
	uni.hideLoading()
},2000)
7: Prompt box with mask
//如果有透明蒙层,相当于全屏 不能做其他操作如点击事件
uni.showToast({
    
    
	title: '遮罩层的弹窗',
	duration: 2000,
	mask: true //是否有透明蒙层,默认为false 
})
7: There is a list (pull-up list) prompt box
uni.showActionSheet({
    
    
	itemList: ['A', 'B', 'C'],
	success (res) {
    
    
		console.log(res.tapIndex)
	},
	fail (res) {
    
    
		console.log(res.errMsg)
	}
})

Additional and useful information that may appear has been commented.
Other questions about uniapp or areas that you do not understand this method can leave a message, I will reply and help you solve it as soon as possible.

Guess you like

Origin blog.csdn.net/weixin_47821281/article/details/108727203