//源代码
const replyStr = `<span style='color: red'>#${item.name}#</span>`;
this.postEditor.setContents({
html: replyStr,
});
使用uniapp的setContents(),初始显示一段红色的文字(1),接着输入新内容(2),会发现新内容的颜色被带成了红色,我想要新输入的内容被显示成原来默认输入的样式怎么办呢?
好办,在replyStr后面加上<i style="font-style: normal;"> </i>
,使初始内容后显示默认样式。
//修改后的代码
const replyStr = `<span style='color: red'>#${item.name}#</span><i style="font-style: normal;"> </i>`;
this.postEditor.setContents({
html: replyStr,
});
好了,我想要的实现了。