html标签和\n的效果如何正确显示?
发布于 4 年前 作者 jinghan 11223 次浏览 来自 问答

例如:

<span>Blow</span> out the candles and make a wish.\n吹蜡烛许愿吧。

这段文字如果是直接写在wxml文件里面能正确显示效果。

但是如果从数据库中取出以{{content}}来显示,<span>标签和\n都直接以文本形式打印出来,请问,怎么样才能显示效果?标签span和\n我写到数据库里面了。

3 回复

使用text标签就可以啊

wxml:

<text>

out the candles and make a wish.\n吹蜡烛许愿吧。

{{haha}}

</text>

js:

data:{

haha:“out the candles and make a wish.\n吹蜡烛许愿吧。” }

效果图:

富文本,我用的rich-text组件,但是不能加事件,只用于显示

使用富文本解析组件wx.parse

https://github.com/icindy/wxParse

回到顶部