diff --git a/packages/uni-mp-compiler/__tests__/test.ts b/packages/uni-mp-compiler/__tests__/test.ts
index 070f67a3da77a2de4229d2352d676d1f1fc6f5f0..0402c5e0a51a4b566d0ce124cd6c95cd0557c70f 100644
--- a/packages/uni-mp-compiler/__tests__/test.ts
+++ b/packages/uni-mp-compiler/__tests__/test.ts
@@ -36,7 +36,7 @@ function assert(
}
assert(
- `{{ slotProps.item }}`,
+ ``,
``,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, index, i0) => { return { a: _r(\"default\", { key: index }) }; }) }
diff --git a/packages/uni-mp-compiler/__tests__/vIf.spec.ts b/packages/uni-mp-compiler/__tests__/vIf.spec.ts
index a65cecd083d69dd91916286d4c928ed12f461932..53547f4bd405dc1bbcbb6d8023c644850e81b42a 100644
--- a/packages/uni-mp-compiler/__tests__/vIf.spec.ts
+++ b/packages/uni-mp-compiler/__tests__/vIf.spec.ts
@@ -175,6 +175,16 @@ describe(`compiler: v-if`, () => {
test(`v-on with v-if`, () => {
//
})
+
+ test(`v-for + v-if + v-else`, () => {
+ assert(
+ ``,
+ ``,
+ `(_ctx, _cache) => {
+ return { a: _f(_ctx.items, (item, k0, i0) => { return _ctx.ok ? { a: '2a9ec0b0-0' + '-' + i0 } : { b: item.title, c: '2a9ec0b0-1' + '-' + i0 }; }), b: _ctx.ok }
+}`
+ )
+ })
})
describe('errors', () => {
diff --git a/packages/uni-mp-compiler/src/transform.ts b/packages/uni-mp-compiler/src/transform.ts
index 94523b76bf130b4dc7d4e3befc17670e8a34cfcf..ba896bafaf935bb0e9960a63fc3315a7caa7bcf2 100644
--- a/packages/uni-mp-compiler/src/transform.ts
+++ b/packages/uni-mp-compiler/src/transform.ts
@@ -126,7 +126,10 @@ export function isRootScope(scope: CodegenScope): scope is CodegenRootScope {
}
export function isVIfScope(scope: CodegenScope): scope is CodegenVIfScope {
- return !!(scope as CodegenVIfScope).condition
+ return (
+ !!(scope as CodegenVIfScope).condition ||
+ (scope as CodegenVIfScope).name === 'else'
+ )
}
export function isVForScope(scope: CodegenScope): scope is CodegenVForScope {