关键词搜索一个列表,需要关键词高亮,我的思路是把字符串中的关键词替换成类似:
“<text class=‘light-keyword’>” + word + “</text>”
这样会被解析成字符串,如何解析成一个节点
<rich-text nodes="{{item.tmpl}}"/></view>
t = t.replace(/{aa}/g, “<span style=‘color:red;’>” + da.data.aa + “</span>”);
小程序目前不支持,建议用第三方插件吧,推荐wxParse