8000 fix: fix v-if in ActionBar · shirakaba/nativescript-vue@95054ee · GitHub
[go: up one dir, main page]

Skip to content

Commit 95054ee

Browse files
committed
fix: fix v-if in ActionBar
fix nativescript-vue#76
1 parent 821d726 commit 95054ee

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

platform/nativescript/element-registry.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,17 @@ registerElement(
113113
)
114114
registerElement(
115115
'NativeActionBar',
116-
() => require('tns-core-modules/ui/action-bar').ActionBar
116+
() => require('tns-core-modules/ui/action-bar').ActionBar,
117+
{
118+
removeChild(parent, child) {
119+
try {
120+
parent.nativeView._removeView(child.nativeView)
121+
} catch (e) {
122+
// ignore exception - child is likely already removed/replaced
123+
// fixes #76
124+
}
125+
}
126+
}
117127
)
118128
registerElement(
119129
'NativeActionItem',

samples/app/76.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const Vue = require('./nativescript-vue')
2+
3+
Vue.config.debug = true
4+
Vue.config.silent = false
5+
6+
new Vue({
7+
data: {
8+
selectedTab: 0
9+
},
10+
template: `
11+
<Frame>
12+
<Page>
13+
<ActionBar title="Issue #76">
14+
<SearchBar v-if="selectedTab === 0" />
15+
<Label v-else-if="selectedTab === 1" text="Second" />
16+
<Label v-else text="Third" />
17+
</ActionBar>
18+
<StackLayout>
19+
<TabView v-model="selectedTab">
20+
<TabViewItem title="First">
21+
<Label text="First"/>
22+
</TabViewItem>
23+
<TabViewItem title="Second">
24+
<Label text="Second"/>
25+
</TabViewItem>
26+
<TabViewItem title="Third">
27+
<Label text="Third"/>
28+
</TabViewItem>
29+
</TabView>
30+
</StackLayout>
31+
</Page>
32+
</Frame>
33+
`,
34+
created() {
35+
console.log(Vue.compile(this.$options.template).render.toString())
36+
}
37+
}).$start()

0 commit comments

Comments
 (0)
0