美文网首页
uni-app点击按钮显示消息提示框-uni.showToast

uni-app点击按钮显示消息提示框-uni.showToast

作者: 祈澈菇凉 | 来源:发表于2021-06-30 00:01 被阅读0次

    参考文档:https://uniapp.dcloud.io/api/ui/prompt?id=showmodal

    示例:

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

    test.vue

    <template>
        <button @click.stop="isLeave()">点击按钮</button>
    </template>
    <script>
        export default {
            data() {
                return {};
            },
            onLoad() {},
            methods: {
                isLeave(id) {
                    uni.showToast({
                        title: '消息提示',
                        icon: 'none'
                    });
                },
            },
        }
    </script>
    <style>
    </style>
    

    运用,在提交表单的时候,可以做一个判断,如果不符合提交要求,可以直接显示消息提示框,作为一个提示哦

    这里的参数icon所对应的数值,我在上面给设置成了none,不显示图标
    一般可以根据相关的需求进行设置的

    比如success:显示成功图标,此时 title 文本最多显示 7 个汉字长度。默认值

     uni.showToast({
                        title: '消息提示',
                        icon: 'success'
                    });
    

    比如:loading显示加载图标,此时 title 文本最多显示 7 个汉字长度。

    uni.showToast({
                        title: '消息提示',
                        icon: 'loading'
                    });
    

    相关文章

      网友评论

          本文标题:uni-app点击按钮显示消息提示框-uni.showToast

          本文链接:https://www.haomeiwen.com/subject/fndkultx.html