提交 3df3f052 编写于 作者: fxy060608's avatar fxy060608

fix(mp): v-else

上级 47ebbf76
......@@ -36,7 +36,7 @@ function assert(
}
assert(
`<custom><template v-slot:default="slotProps"><view>{{ slotProps.item }}</view></template></custom>`,
`<view v-for="item in items"><uni-icons v-if="ok"/><uni-icons v-else :title="item.title"/></view>`,
`<slot wx:for="{{a}}" wx:for-item="item"></slot>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, index, i0) => { return { a: _r(\"default\", { key: index }) }; }) }
......
......@@ -175,6 +175,16 @@ describe(`compiler: v-if`, () => {
test(`v-on with v-if`, () => {
// <button v-on="{ click: clickEvent }" v-if="true">w/ v-if</button>
})
test(`v-for + v-if + v-else`, () => {
assert(
`<view v-for="item in items"><uni-icons v-if="ok"/><uni-icons v-else :title="item.title"/></view>`,
`<view wx:for="{{a}}" wx:for-item="item"><uni-icons wx:if="{{b}}" u-i="{{item.a}}"/><uni-icons wx:else title="{{item.b}}" u-i="{{item.c}}"/></view>`,
`(_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', () => {
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册