提交 82ad8854 编写于 作者: Q qiang

fix(mp): 修复 v-for 循环 wxs 模块内容报错的问题 question/115658

上级 884fec90
...@@ -27,6 +27,17 @@ describe('mp:compiler-extra', () => { ...@@ -27,6 +27,17 @@ describe('mp:compiler-extra', () => {
} }
} }
) )
assertCodegen(
/* eslint-disable no-template-curly-in-string */
'<view v-for="(item, index) in a.test()" :key="index">{{item}}</view>',
'<block wx:for="{{a.test()}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view>{{item}}</view></block>',
'with(this){}', {
filterModules: {
t: {},
a: {}
}
}
)
}) })
it('generate scopeId', () => { it('generate scopeId', () => {
......
...@@ -16,7 +16,8 @@ const { ...@@ -16,7 +16,8 @@ const {
traverseKey, traverseKey,
processMemberExpression, processMemberExpression,
getForIndexIdentifier, getForIndexIdentifier,
isSimpleObjectExpression isSimpleObjectExpression,
traverseFilter
} = require('../../util') } = require('../../util')
const getMemberExpr = require('./member-expr') const getMemberExpr = require('./member-expr')
...@@ -185,7 +186,7 @@ module.exports = function traverseRenderList (path, state) { ...@@ -185,7 +186,7 @@ module.exports = function traverseRenderList (path, state) {
} }
}) })
} }
} else if (forPath.isCallExpression() || (forPath.isObjectExpression() && !isSimpleObjectExpression(forPath.node))) { } else if ((forPath.isCallExpression() && !traverseFilter(forPath.node.callee, state)) || (forPath.isObjectExpression() && !isSimpleObjectExpression(forPath.node))) {
forPath.replaceWith(getMemberExpr(forPath, IDENTIFIER_FOR, forPath.node, forState)) forPath.replaceWith(getMemberExpr(forPath, IDENTIFIER_FOR, forPath.node, forState))
} else { } else {
forPath.traverse(require('./visitor'), forState) forPath.traverse(require('./visitor'), forState)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册