学无先后,达者为师

网站首页 编程语言 正文

ant 循环多条通知提醒框堆叠问题

作者:青色柠檬雨 更新时间: 2023-12-07 编程语言

 ant 低版本中循环多条通知时通知提示框会出现堆叠的问题最后一条会显示在界面上,关闭第一条才会显示倒数第二条信息,我想要所有通知都平铺,用Promise 或者nextTick和setTimeout都可以达到效果,我这里用了Promise

  // data中定义  tippromise: Promise.resolve(),   
 funtIp() {
 var   tip= [
                { title: "信息一", text: "病人一", key: 1 },
                { title: "信息二", text: "病人二", key: 2 },
                { title: "信息三", text: "病人三", key: 3 },
            ],
            this.tip.forEach(res => {
                const key = res.key;
                this.tippromise = this.tippromise.then(() => {
                    this.$notification.open({
                        message: `预警信息 `,//${placement}
                        description: res.title,

                        placement: "bottomRight",
                        duration: 0,

                        btn: h => {
                            return h(
                                'a-button',
                                {
                                    props: {
                                        type: 'primary',
                                        size: 'small',
                                    },
                                    on: {
                                        click: () => this.$notification.close(key),
                                    },
                                },
                                '已读',
                            );
                        },
                        key,
                        onClose: close,
                    });

                })
            })

            //   openNotification() {

            // },

        },

效果

原文链接:https://blog.csdn.net/lfalt/article/details/133807560

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新