------------恢复内容开始------------

新建filter.wxs文件,文件内容如下

var format = function (text) {
if (!text) {
return
}
var reg = getRegExp('\\\\n', 'g')
return text.replace(reg,'\n')
}

module.exports = {
format:format
}
————————————————


在需要使用的wxml中导入wxs模块

<!--导入wxs模块,只能使用相对路径,并需要定义module-->
<wxs src="../filter.wxs" module="util"></wxs>

 

在text标签中使用时,需要使用util.format()的方法j将服务器返回的数据当做参数传到方法中就可以了

<text class="content">{{util.format(book.summary)}}</text>
 

------------恢复内容结束------------

posted on 2020-08-13 10:41  心意如水hucuie22  阅读(326)  评论(0编辑  收藏  举报