Skip to content

Commit 7ba5b1b

Browse files
committed
Auto generate template name when a condition is provided.
1 parent 5a9e377 commit 7ba5b1b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { patch } from '../patch'
22

33
export const VUE_VIEW = '__vueVNodeRef__'
44

5+
let tid = 0
56
export default {
67
name: 'v-template',
78

89
props: {
910
name: {
10-
type: String,
11-
default: 'default'
11+
type: String
1212
},
1313

1414
if: {
@@ -23,7 +23,7 @@ export default {
2323

2424
this.$parent.$templates = this.$parent.$templates || new TemplateBag()
2525
this.$parent.$templates.registerTemplate(
26-
this.$props.name,
26+
this.$props.name || (this.$props.if ? `v-template-${tid++}` : 'default'),
2727
this.$props.if,
2828
this.$scopedSlots.default
2929
)

samples/app/app-with-v-template.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ new Vue({
3838
<Label :text="item.value" style="color: blue;"/>
3939
</StackLayout>
4040
</v-template>
41-
<v-template name="test" if="item.odd">
41+
<v-template if="item.value.length == 2">
42+
<StackLayout style="padding: 50;">
43+
<Label :text="item.value" style="color: green;"/>
44+
</StackLayout>
45+
</v-template>
46+
<v-template if="item.odd">
4247
<StackLayout style="padding: 50;">
4348
<Label :text="item.value" style="color: red;"/>
4449
</StackLayout>

0 commit comments

Comments
 (0)