setData页面渲染效率
调用wxparse组件解析HTML,上拉一次显示十条列表,当列表有几十条时明显setData页面再次渲染耗时成倍增加,有什么优化思路吗?setData应该只刷新新增加的部分,为啥会越来越慢?
for (let i = 0; i < replyArr.length; i++) { WxParse.wxParse( 'reply' + i, 'html' , replyArr[i], that); if (i === replyArr.length - 1) { WxParse.wxParseTemArray( "replyTemArray" , 'reply' , replyArr.length, that) } } |
function wxParseTemArray(temArrayName,bindNameReg,total,that){ var array = []; var temData = that.data; var obj = null ; for ( var i = 0; i < total; i++){ var simArr = temData[bindNameReg+i].nodes; array.push(simArr); } temArrayName = temArrayName || 'wxParseTemArray' ; obj = JSON.parse( '{"' + temArrayName + '":""}' ); obj[temArrayName] = array; that.setData(obj);//渲染页面,耗时 } |