omi-mp - fix parse error

This commit is contained in:
张磊 2018-12-03 17:01:09 +08:00
parent 07e9d2cb0b
commit 190a9178a3
1 changed files with 3 additions and 1 deletions

View File

@ -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}])`
}