diff --git a/packages/omi-cli/package.json b/packages/omi-cli/package.json index 1cc63169a..c7a24cdcf 100755 --- a/packages/omi-cli/package.json +++ b/packages/omi-cli/package.json @@ -1,6 +1,6 @@ { "name": "omi-cli", - "version": "3.0.27", + "version": "3.0.28", "description": "Create website with no build configuration. be friendly to [Omi](https://github.com/Tencent/omi) framework.", "main": "bin/omi", "engines": { diff --git a/packages/omi-cli/template/mp/scripts/mp/parse.js b/packages/omi-cli/template/mp/scripts/mp/parse.js index 5cf27320a..314bb0d63 100644 --- a/packages/omi-cli/template/mp/scripts/mp/parse.js +++ b/packages/omi-cli/template/mp/scripts/mp/parse.js @@ -123,21 +123,21 @@ function _walk(node, currentIndex, children) { let index = node.attr['wx:for-index'] || 'index' let item = node.attr['wx:for-item'] || 'item' let current = `${str}.map((${item},${index})=>{ - return ${c} + return h('${map(node.tag)}',${stringify( + node.attr, + map(node.tag) + )}, + ${c} + ) })` delete node.attr['wx:for'] delete node.attr['wx:for-items'] delete node.attr['wx:for-index'] delete node.attr['wx:for-item'] - if (node.tag == 'block') { - result = `${ifCond} [${current}]` - } else { - result = `${ifCond}h('${map(node.tag)}',${stringify( - node.attr, - map(node.tag) - )},${current})` - } + + result = `${ifCond} ${current}` + } else if (node.tag == 'block') { result = isArray ? `${ifCond} [${c}]` : `${ifCond} ${c}` } else { diff --git a/packages/omi-mp-douban/scripts/mp/parse.js b/packages/omi-mp-douban/scripts/mp/parse.js index 5cf27320a..314bb0d63 100644 --- a/packages/omi-mp-douban/scripts/mp/parse.js +++ b/packages/omi-mp-douban/scripts/mp/parse.js @@ -123,21 +123,21 @@ function _walk(node, currentIndex, children) { let index = node.attr['wx:for-index'] || 'index' let item = node.attr['wx:for-item'] || 'item' let current = `${str}.map((${item},${index})=>{ - return ${c} + return h('${map(node.tag)}',${stringify( + node.attr, + map(node.tag) + )}, + ${c} + ) })` delete node.attr['wx:for'] delete node.attr['wx:for-items'] delete node.attr['wx:for-index'] delete node.attr['wx:for-item'] - if (node.tag == 'block') { - result = `${ifCond} [${current}]` - } else { - result = `${ifCond}h('${map(node.tag)}',${stringify( - node.attr, - map(node.tag) - )},${current})` - } + + result = `${ifCond} ${current}` + } else if (node.tag == 'block') { result = isArray ? `${ifCond} [${c}]` : `${ifCond} ${c}` } else {