Website:Github.com/icindy/wxPa…



JS

Var WxParse = require(' your path/WxParse /html2json.js'); // WxParse page({onLoad:function(){// Request data; I'm not going to write it here. var result = r.data.data; var list = result.templist; Var htmlAry=[]; for (let i = 0; i < list.length; i++) { if (list[i].type == 'text') { htmlAry[i] = WxParse.html2json(list[i].content, 'returnData'); // The point is right here. Just do this and get the converted Node format data directly; console.log(htmlAry[i]); }} that.setdata ({templist: list, htmlAry: htmlAry,// remember to add} here); }})Copy the code

wxml

<template is="wxParse" data="{{wxParseData:htmlAry[0].nodes}}" />
Copy the code

That’s it. That’s it. Of course MY example is simple, but the logic of this call is simple.

It can be called individually, in a loop, or in a conditional loop!