element中使用$notify在提示信息中换行问题

本文详细解析了使用Vue和Element UI实现环境监测警告通知的代码片段,包括如何创建警告通知、显示气体类型名称、气体浓度、温度和湿度等信息,并介绍了使通知内容保持原有格式的样式设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

const h = this.$createElement
      this.instance = this.$notify({
        type: 'warning',
        dangerouslyUseHTMLString: true,
        title: this.warningGasInfo.gasTypeName,
        message: h('a', '甲烷: ' + this.warningGasInfo.ch4 + '% 一氧化碳:' + this.warningGasInfo.co + 'ppm 氧气:' +
                this.warningGasInfo.o2 + '%' + '\n' + '温度:' + this.warningGasInfo.temperature + '℃ 湿度:' + this.warningGasInfo.humidity + '%'),
        duration: 0
      })

使用方式如下:

this.o2 + '%' + '\n' + '温度:'+ this.temperature

在对应的样式中加入white-space:pre这个样式即可

.el-notification {white-space:pre !important; }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值