index.wxml
{{content}}
index.js
const app = getApp()
Page({
data: {
content: 'Hello World',
},
onLoad: function(){
var that = this;
wx.request({
url: '测试域名',
success: function(res){
console.log(res);
that.setData({
content: res.data
});
}
});
}
})
运行结果
that.setData({
content: res.data.replace(/\\n/g, '\n')
});
<wxs module="handler">
module.exports = function(text) {
if(text)
return text.replace(getRegExp('\\\\n','g'), '\n')
}
</wxs>
<text>{{handler(content)}}</text>