Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  62] [ 7]  / answers: 1 / hits: 18481  / 9 Years ago, fri, december 11, 2015, 12:00:00

I have a template that loops using v-for. In the template I have a named slot with the name being dynamically assigned in the loop. No content is appearing, what am I doing wrong?



<todo-tabs :list=items>
<div slot=interview>Interview</div>
<div slot=membership>Membership</div>
<div slot=profile>Profile</div>
<div slot=handoff>Handoff</div>
</todo-tabs>

<template id=todo-tabs>
<div class=tab-content >
<div v-for=item in list :class={'active': item.current} class=tab-pane id=@{{ item.id }}>
<div class=skin skin-square>
<form class=form-horizontal role=form>
<div class=form-body>
<slot name=@{{ item.id }}></slot>
</div>
<div class=form-actions>
<button type=submit class=btn red btn-outline>Submit</button>
<button type=button class=btn default>Cancel</button>
</div>
</form>
</div>
</div>
</div>
</template>

<script>
Vue.component('todo-tabs', {
template: '#todo-tabs',
props: ['list']
});
var vm = new Vue({
el: #todo,
data: {
items : [
{id: 'interview', name: 'interview', complete: true, body: 'something1', step_content: 'SOME' },
{id: 'membership', name: 'membership', complete: false, body: 'something2', step_content: 'SOME' },
{id: 'profile', name: 'profile', complete: false, body: 'something3', step_content: 'SOME', current: true },
{id: 'handoff', name: 'handoff', complete: false, body: 'something4', step_content: 'SOME'}
]
}
});
</script>

More From » vue.js

 Answers
75

in VueJS 1.0.16 you could do this in your template:



<div v-for=item in tiems>
<slot :name=item.id></slot>
</div>


However, as of 1.0.17 VueJS throws this error: <slot :name=item.id>: slot names cannot be dynamic.


[#64097] Wednesday, December 9, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keric

Total Points: 572
Total Questions: 93
Total Answers: 97

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;