element notification消息自动换行和自定义样式

1、使用div标签进行自动换行

使用div标签可以完美实现,关键在于style两句css样式

this.$notify({
          title: '当前用户信息',
          message: this.$createElement('div', { style: ' word-wrap: break-word;word-break:break-all'}, '用户信息内容'),
          type:"info",//主题样式
          offset: 10,//偏移距离
          duration: 0,//消息存在时间,0表示一直存在
          customClass:'notifyStyle',//自定义类名
        });

2、自定义修改notification通知框样式

上面代码中可以添加customClass自定义类名,然后在本vue页面添加style样式。

添加一个新的不加scope的style标签,在每一个样式后加上!important进行加权,然后即可自定义修改notification样式。如下:

<style>
.notifyStyle{
  width: 500px !important;
}
</style>

3、防止notification消息通知重叠的办法

只需要在每一个this.$notify{}外部用

this.notificationPromise = this.notificationPromise.then(this.$nextTick).then(()=>{});包裹即可,例子如下:
data(){
return{
notificationPromise:Promise.resolve(),
}
}

methods:{

handeclick(){
this.notificationPromise = this.notificationPromise.then(this.$nextTick).then(()=>{
            this.$notify({
              title: '当前用户信息',
              message: this.$createElement('div', {style: 'word-wrap:break-word;word-break:break-all;font-weight:bold;color:blue'}, '用户信息'),
              type: "info",
              offset: 0,//偏移距离
              duration: 5000,//消息存在时间,0表示一直存在
              customClass: 'notifyStyle',//自定义类名,可修改样式
            });
          });
}
}

 

  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值