wxParse 嵌套循环 如何设置?
发布于 5 年前 作者 luona 11583 次浏览 来自 问答

  <view wx:for="{{OptionsArray_0}}" wx:key=“idx”>

        <template is=“wxParse” data="{{wxParseData:item}}" />

      </view>

这里的 OptionsArray_0  可否动态设置 为 ‘OptionsArray_’+index  这是嵌套循环,主要解析富文本内容

2 回复

动态的变量值没找到如何去写,可以改成 aaa[‘bbb’+index],把你的单个item放到一个数组里面,wxParseTemArray 方法只是直接push进去,图片计算的方法获取不到图片无法计算高度,所以需要改造下官方的wxParse,传入多级对象去解析,github上有人修改了 ,替换wxParse.js  html2json.js

https://github.com/yadewe/wxParse/tree/5dce7c4efb1311e8b603e2fff4b4888b13ba0415/wxParse

<template is="wxParse" data="{{wxParseData:editors['editor'+item.id].nodes}}" />
 
 
 
this.data.moduleData.forEach((item) => {
 
    if (item.type === 1) {
 
        WxParse.wxParse('editors.editor' + item.id, 'html', item.content.fulltext, this);
 
    }
 
})

我也遇到这样问题 无法解决

回到顶部