转载至:http://blog.csdn.net/tang05709/article/details/54924675
这个是需要循环出显示的
https://github.com/tonyzhan/cnodeWeixinApp/blob/master/pages/detail/detail.wxml
首先去 https://github.com/icindy/wxParse 下载wxParse,只拷贝wxParse文件夹即可。
1、引入wxss
@import "../wxParse/wxParse.wxss";
2、引入wxml
<import src="../wxParse/wxParse.wxml"/>
<view class="wxParse">
<template is="wxParse" data="{{wxParseData:article_content.nodes}}"/>
</view>
3、引入js并加载数据
var app = getApp();
var WxParse = require('../wxParse/wxParse.js');
Page({
data: {
motto: 'jxcat',
serverUrl: app.globalData.ajaxUrl,
baseUrl: app.globalData.baseUrl,
title: "文章详情",
article_title: "",
article_content: "",
},
onLoad: function (options) {
var that = this
var result
//serverUrl = app.globalData.ajaxUrl
wx.request({
url: app.globalData.ajaxUrl,
data: {
m: 'api',
c: 'article' ,
a: 'info',
aid: options.aid
},
header: {
'content-type': 'application/json'
},
success: function(res) {
that.setData({
article_title:res.data.article_title,
article_content:WxParse.wxParse('article_content', 'html', res.data.article_content, that, 5)
})
}
})
//request
}
})