欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

elementui中Notification组件添加点击事件、传参数

程序员文章站 2022-04-27 11:44:04
1. 官方文档2. 代码handleClick() { let telNo = "1111", message = "22222", _this = this; //函数作用域问题 this.$notify({ title: "通知消息", position: "bottom-right", dangerouslyUseHTMLString: true, message: `

号码...

1. 官方文档

elementui中Notification组件添加点击事件、传参数

2. 添加点击事件,传参

handleClick() {
 let telNo = "1111",
    message = "22222",
    _this = this; //函数作用域问题

  this.$notify({
    title: "通知消息",
    position: "bottom-right",
    dangerouslyUseHTMLString: true,
    message: `<p style="cursor: pointer;">号码:<i>${telNo}</i></p>`,
    duration: 0,
    type: "warning",
    onClick() {
      _this.defineCallBack(message); //自定义回调,message为传的参数
    }
  });
},

//点击事件回调
defineCallBack(message) {
  console.log(message);
},

3. 按一定顺序弹出消息通知

 //按一定顺序弹出消息通知
notifyByOrder() {
  let data = ["aaaa", "bbbbb", "ccccc"];
  for (let i = 0; i < data.length; i++) {
    let item = data[i];
    setTimeout(() => {
      this.$notify({
        title: `通知${i + 1}`,
        position: "bottom-right",
        message: `通知内容${item}`,
        duration: 0,
        type: "warning"
      });
    }, i * 5000);
  }
}

本文地址:https://blog.csdn.net/qq_41839808/article/details/107519485

相关标签: vue