uniapp 中uni.showToast()的各种写法

1.显示提交成功

uni.showToast({
title: '提交成功',
icon: 'none',  //success 等
duration: 1000
});

2.显示加载中 2s后消失(可以接口掉完消失)

uni.showLoading({                      
    title: '加载中'
});
                    
setTimeout(function () {
        uni.hideLoading();
}, 2000);

3.确认取消提示框

uni.showModal({
        title: '提示',
        content: '确认删除该条信息吗?',
        success: function(res) {
        if (res.confirm) {
            // 执行确认后的操作
        } 
        else {
            // 执行取消后的操作
        }
    }
})

4. 自定义取消、确认的内容。

uni.showModal({
			        title: '提示',
			        // 提示文字
			        content: '确认删除该条信息吗?',
			        // 取消按钮的文字自定义
			        cancelText: "取消",
			        // 确认按钮的文字自定义
			        confirmText: "删除",
			        //删除字体的颜色
			        confirmColor:'red',
			        //取消字体的颜色
			        cancelColor:'#000000',
			        success: function(res) {
			        if (res.confirm) {
			            // 执行确认后的操作
			        } 
			        else {
			            // 执行取消后的操作
			        }
			    }
			})

5、列表选择提示弹框

uni.showActionSheet({
			    itemList: ['选项一', '选项二', '选项三'],
			    // 字体颜色
			    itemColor: "#55aaff",
			    success (res) {
			       // 选择其中任意一项后,获取其索引(res.tapIndex),从0开始
			       console.log(res.tapIndex) 
			    },
			    fail (res) {
			       // 取消后的操作
			    }
			})

猜你喜欢

转载自blog.csdn.net/lanbaiyans/article/details/130573584
今日推荐