2👍
Ok. I already figure it out. v-bind="{id: square}"
make the trick
Vue.component('select-square', {
template:'#select-square',
data: function (){
return {squares:''}
},
components:{
'square-template' : {
template: '#square-template'
}
}
});
new Vue({
el: 'body',
data: {
screens:'',
}
});
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.min.js"></script>
<select class="form-control" v-model="screens" number>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<div v-for="screen in screens">
<select-square></select-square>
</div>
<template id="select-square">
<select class="form-control" v-model="squares" number>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<square-template v-bind="{id: square}" v-for="square in squares"></square-template>
</template>
<template id="square-template">
<input>
</template>
0👍
Well, in your ready method you can watch for the screens changes like
data: function(){
return {
screens: 0,
newSelectScreens: 0
}
},
ready: function(){
this.$watch('screens', function(){
this.newSelectScreens = this.screens;
});
}
Then for the new select screens
<select v-for="n in newSelectScreens">
<options></options>
</select>
👤Ogie
Source:stackexchange.com