【uni-app】UniApp常用实例参考笔记(自己开发项目用)

1、显示自动消失(title内容最多7个汉字)

uni.showToast({
    title: '标题',
    duration: 2000
});

2、解除title内容的字数限制

<template>
	<view>
		<u-toast ref="uToast" />
	</view>
</template>
<script>
    export default {
        methods: {
            showToast() {
            this.$refs.uToast.show({
                title: '这样就没有字数限制了',
                duration: 6000
            })
                
            }
        }
    }
</script>

3、弹出,需要操作

uni.showModal({
    title: '提示',
    content: '这是一个模态弹窗',
    success: function (res) {
        if (res.confirm) {
            console.log('用户点击确定');
        } else if (res.cancel) {
            console.log('用户点击取消');
        }
    }
});

猜你喜欢

转载自blog.csdn.net/dxnn520/article/details/129444763