Mini Program is a novice. In the course of practice, he found that there is a html tag in the interface.
searched the wxParse, reference tutorial of the ODR. My code is as follows:
Json is structured like this:
{
"meta": {
...
},
"pages": [
{...}
],
"posts": [
{
"title": "...",
"content": "html
\n"
}
{
"title": "...",
"content": "html
\n"
}
]
}
my app.js:
App({
onLaunch: function (options) {
var that = this;
wx.request({
url: "https://www.sfatpaper.com/content.json",
success(res) {
that.globalData.posts = res.data.posts
}
})
},
globalData: {
posts: ""//
}
})
my logs.wxml:
<navigator url="/pages/details/details?id={{item.date}}" class="posts" wx:for="{{posts}}" wx:for-index="idx" wx:for-item="item" wx:key="idx">
<view class="title">{{item.title}}</view>
<text>{{item.text}}</text>
</navigator>
-the question has been adjusted through the answer on the first floor, and the current question code is as follows-
my details.js:
// pages/posts/posts.js
var WxParse = require("../../wxParse/wxParse.js");
const app = getApp();
Page({
data: {
title: "",
contents: ""
},
onLoad: function (options) {
var that = this;
that.setData({
posts: app.globalData.posts
})
//
that.data.posts.map(function (item, idx) {
if (item.date == options.id) {
//WxParsemap
console.log("item.content:"+item.content) //
var parseText = WxParse.wxParse("article", "html", item.content, that, 5)
console.log("parseText:" + parseText) //parseText:undefined
//WxParse
that.setData({
title: item.title,
content: item.content
})
}
})
}
})
Click on the list to bring the parameters in url to the details page, and then the details page uses the parameters to Filter the posts data, and finally obtains the unique content, and then wxParse, it, but I don"t know what will still be reported to me parseText:undefined
on the foreground rendering, the page renders only the first paragraph of the article.