小程序使用wxParse解析html
轉(zhuǎn)載至:http://blog.csdn.net/tang05709/article/details/54924675
?
這個(gè)是需要循環(huán)出顯示的
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并加載數(shù)據(jù)
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
? }
})
轉(zhuǎn)載于:https://www.cnblogs.com/ch-zaizai/p/7418364.html
總結(jié)
以上是生活随笔為你收集整理的小程序使用wxParse解析html的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: oc40--类的启动过程
- 下一篇: 函数和常用模块【day04】: 总结(十