From 587b29e48a0643e0881312b768887491e6a37a18 Mon Sep 17 00:00:00 2001 From: qiang Date: Wed, 13 Apr 2022 17:48:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(mp):=20=E4=BF=AE=E5=A4=8D=20v-for=20?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=20key=20=E6=97=B6=E4=BC=9A=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BD=9C=E7=94=A8=E5=9F=9F=E6=8F=92=E6=A7=BD=20key=20=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-template-compiler/__tests__/compiler-extra.spec.js | 4 ++++ packages/uni-template-compiler/lib/util.js | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js index d5b1d2d63..fe8a67f47 100644 --- a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js @@ -279,6 +279,10 @@ describe('mp:compiler-extra', () => { '', '' ) + assertCodegen( + '', + 'text' + ) // TODO vue的数字 item 是从1,小程序是从0,后续考虑抹平差异 assertCodegen( '1', diff --git a/packages/uni-template-compiler/lib/util.js b/packages/uni-template-compiler/lib/util.js index a25958200..fa0ef6afa 100644 --- a/packages/uni-template-compiler/lib/util.js +++ b/packages/uni-template-compiler/lib/util.js @@ -4,7 +4,8 @@ const babelGenerate = require('@babel/generator').default const uniI18n = require('@dcloudio/uni-cli-i18n') const { - METHOD_RENDER_LIST + METHOD_RENDER_LIST, + METHOD_RESOLVE_SCOPED_SLOTS } = require('./constants') function cached (fn) { @@ -48,6 +49,8 @@ function traverseKey (ast, state) { CallExpression (path) { if (path.node.callee.name === METHOD_RENDER_LIST) { path.stop() + } else if (path.node.callee.name === METHOD_RESOLVE_SCOPED_SLOTS) { + path.skip() } } }) -- GitLab