From 190a9178a38389c41017b2c99749d788972b9803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A3=8A?= Date: Mon, 3 Dec 2018 17:01:09 +0800 Subject: [PATCH] omi-mp - fix parse error --- packages/omi-mp/scripts/mp/parse.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/omi-mp/scripts/mp/parse.js b/packages/omi-mp/scripts/mp/parse.js index b017bea41..5cf27320a 100644 --- a/packages/omi-mp/scripts/mp/parse.js +++ b/packages/omi-mp/scripts/mp/parse.js @@ -16,6 +16,7 @@ function minifier(wxml) { function checkIsArray(json) { let count = 0 + if(!json.child) return false for (let i = 0, len = json.child.length; i < len; i++) { let tagName = json.child[i].tag if (tagName) { @@ -54,6 +55,7 @@ function walk(node, fnName) { function _walk(node, currentIndex, children) { let c = '' + let isArray = checkIsArray(node) let result = '' if (node.node === 'text') { let text = node.text.trim().replace(/\\n/g, '') @@ -137,7 +139,7 @@ function _walk(node, currentIndex, children) { )},${current})` } } else if (node.tag == 'block') { - result = `${ifCond} [${c}]` + result = isArray ? `${ifCond} [${c}]` : `${ifCond} ${c}` } else { result = `${ifCond}h('${map(node.tag)}',${stringify(node.attr, map(node.tag))},[${c}])` }