1.1 问题描述
因业务需求要求 ant 的 notification 通知框中内容 需要支持 html标签。
1.2 解决方案
根据 官方文档的API 可以看出,提示内容可以采用以下3种类型方式。于是 选择第二种 vueNode
方式。
核心代码如下:
/**
* 其中 domProps: { innerHTML: errorMsg } 核心关键,然后 errorMsg 可以携带html标签了
* 同时还可以进行其他属性配置,具体查看 https://www.cnblogs.com/yuxiaole/p/9353031.html
*/
const h = this.$createElement;
this.$notification.error({
key: notificationKey,
message: "温馨提示",
description: h("div", null, [
h("p", { domProps: { innerHTML: errorMsg } }, null),
]),
duration: 0,
placement: "bottomLeft",
});