showToast、hideToast

复制代码
<template>
    <button @click="show">显示</button>
    <button @click="hide">隐藏</button>
</template>

<script setup>
    const show = () => {
        uni.showToast({
            duration:3000, // 持续时间
            mask:false, // 全屏遮罩层,未消失前会不可点击
            icon:'loading', // success、error、fail、exception、none、loading
            title:'成功', // 有icon或者image时最多展示7个字
            image: '/static/logo.png' ,// 跟icon冲突,优先级更高
            success:(e) => {
                console.log('接口成功时执行的回调函数',e)
            },
            fail: (e) => {
                console.log('接口失败时执行的回调函数',e)
            },
            complete: (e) => {
                console.log('接口不管成功或者失败时执行的回调函数',e)
            }
        })
    }
    const hide = () => {
        uni.hideToast()
    }
</script>
复制代码

 

posted on   ChoZ  阅读(4)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示