Skip to content

Commit ba4e994

Browse files
committed
fix: don't create view without data
fix nativescript-vue#229
1 parent 7bf8b10 commit ba4e994

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

platform/nativescript/runtime/components/v-template.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ export class VueKeyedTemplate /* implements KeyedTemplate */ {
101101
}
102102

103103
createView() {
104-
const vnode = this._scopedFn(deepProxy({}))
105-
const nativeView = patch(null, vnode).nativeView
106-
nativeView[VUE_VIEW] = vnode
107-
return nativeView
104+
// we are returning null because we don't have the data here
105+
// the view will be created in the `patchTemplate` method above.
106+
// see https://github.com/nativescript-vue/nativescript-vue/issues/229#issuecomment-390330474
107+
return null
108108
}
109109
}

samples/app/229.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const Vue = require('./nativescript-vue')
2+
3+
Vue.config.silent = false
4+
5+
new Vue({
6+
data: {
7+
items: [{ color: 'red' }, { color: 'blue' }]
8+
},
9+
template: `
10+
<Frame>
11+
<Page>
12+
<ActionBar title="Issue #229" />
13+
14+
<GridLayout>
15+
<ListView for="item in items" class="list-group">
16+
<v-template>
17+
<Label :backgroundColor="item.color" :text="item.color" padding="50" />
18+
</v-template>
19+
</ListView>
20+
</GridLayout>
21+
</Page>
22+
</Frame>
23+
`
24+
}).$start()

0 commit comments

Comments
 (0)