From 97375e74528142d80a847ca4304c5efa2445ceea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A9=B7=E5=B1=8C=E4=B8=9D?= Date: Thu, 10 Oct 2019 11:56:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=AF=91=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=A8=E5=B1=80=E4=BA=8B=E4=BB=B6=E6=8B=A6?= =?UTF-8?q?=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 编译的时候增加全局事件拦截 --- packages/omi-mp/scripts/mp/parse.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/omi-mp/scripts/mp/parse.js b/packages/omi-mp/scripts/mp/parse.js index bbbbbac51..82355e6bc 100644 --- a/packages/omi-mp/scripts/mp/parse.js +++ b/packages/omi-mp/scripts/mp/parse.js @@ -2,6 +2,8 @@ let htmlToJson = require('html2json').html2json let map = require('./tag-mapping') let reURL = /^(https?):\/\/.+$/; + +const inputEvent = ['bindfocus', 'bindkeydown', 'bindkeypree', 'bindkeyup', 'bindinput', 'bindchange', 'bindblue'] function parse(wxml, fnName) { return walk(htmlToJson(minifier(wxml)), fnName) } @@ -28,6 +30,13 @@ function checkIsArray(json) { tagAttr.bindclick = tagAttr.bindtap; } + if(tagName === 'input'){ + inputEvent.forEach((item) => { + if(tagAttr[item]){ + tagAttr[item] = `helpInputEvent.bind(this,this.${tagAttr[item]})` + } + }) + } if (tagName === 'block') { if(tagAttr){ tagAttr.style = '{{{"width": "100%"}}}'; @@ -48,7 +57,6 @@ function checkIsArray(json) { return false } - function walk(node, fnName) { if(checkIsArray(node)){ return `function ${fnName}() {