From f70093d1a7283303065d66951d5ea8de965356ba Mon Sep 17 00:00:00 2001 From: huqi Date: Tue, 3 Nov 2020 18:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87{{each=20()=20}}=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E5=9C=A8=E4=BA=8B=E4=BB=B6=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=B8=AD=E7=BB=91=E5=AE=9A=E5=AD=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- o2web/source/o2_core/o2.js | 22 ++++++++++++++++------ o2web/source/x_component_Empty/Main.js | 7 +++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/o2web/source/o2_core/o2.js b/o2web/source/o2_core/o2.js index c53720f44c..93caca0088 100644 --- a/o2web/source/o2_core/o2.js +++ b/o2web/source/o2_core/o2.js @@ -697,11 +697,11 @@ }else{ dom.insertAdjacentHTML(op.position, data); } - var els = dom.querySelectorAll("[data-o2-element]"); + var els = dom.querySelectorAll("[data-o2-element],[data-o2-events]"); for (var i=0; i1){ node.addEventListener(evs[0], function(e){ - if (m[evs[1]]) m[evs[1]].apply(m, [e]); + if (m[evs[1]]) m[evs[1]].apply(m, [e,data]); }, false); } }); @@ -846,8 +849,15 @@ return {"codeIndex": v.length-1, "lastIndex": v.length-1}; } - var _parseHtml = function(str, json){ + var _parseDataCache = {}; + var _parseHtml = function(str, json, i){ var v = str; + if (i){ + var r = (Math.random()*1000000).toInt().toString(); + while (_parseDataCache[r]) r = (Math.random()*1000000).toInt().toString(); + _parseDataCache[r] = json; + v = (i) ? "
"+str+"
" : str; + } var rex = /(\{\{\s*)[\s\S]*?(\s*\}\})/gmi; var match; @@ -887,7 +897,7 @@ if (eachValue && _typeOf(eachValue)==="array"){ for (var i=0; i