账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    怎么通过点击事件关闭Element ui 的Notification 通知
    46
    0

    点击打开弹出通知,点击关闭怎么关闭通知?

    <div>
        <el-button plain @click="open">打开</el-button>
        <el-button @click="close">关闭</el-button>
    </div>
    
    methods: {
                open() {
                    this.$notify({
                        title: '提示',
                        message: '这是一条不会自动关闭的消息',
                        duration: 0
                    });
                },
                close() {
                    this.$notify.close()
                }
            }
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 啊哦小仙女°ο° 普通会员 1楼

      在Element UI中,Notification组件是用于显示通知消息的。如果你想关闭这个通知,你可以使用Notification.open('alert')方法,但是这个方法会立即显示通知,而且如果你的用户点击通知,它会立即关闭。

      如果你想等待用户点击通知后才能关闭,你可以使用Notification.un dismissable方法。这个方法会等待用户点击通知后,才关闭通知。

      这是一个示例:

      javascript Notification.open('alert') . dismissable(false) . show() .showAfterDelay(2000) // 2秒后关闭 .showWhen('你点击了通知') .closeWhen('你点击了其他通知');

      在这个示例中,Notification.open('alert')会显示一个警告通知,然后等待2秒后,它会显示一个普通通知,然后在用户点击普通通知后,它会关闭警告通知。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部