0
如何在單選按鈕上使用$dispatch()
或$broadcast()
?我不能做這樣的事情(因爲我不能單選按鈕使用v-on:click
):Vue.js使用v-on:使用單選按鈕單擊
HTML
<div class="radio radio-primary">
<label>
<input type="radio" name="intern" id="intern" value="intern"
v-on:click="update" v-model="selectedrole"/>
Showall
</label>
</div>
JS
Vue.component('searchemployees', {
template: '#searchemployees',
data: function()
{
return {
selectedrole: ''
}
},
methods: {
update: function()
{
this.$dispatch('selectedRole', this.selectedrole)
}
}
});
Vue.component('employees', {
template: '#employees',
props:['list'],
data: function()
{
return {
role: ''
}
},
created() {
this.list = JSON.parse(this.list);
},
events: {
'selectedrole': function(role) {
this.role = role
}
}
});
因爲我不能用單選按鈕上的v-on:click
。我怎樣才能做到這一點? (我需要在兩個組件中選擇)。
請幫忙!
這似乎是你問你原來的問題以不同的方式:http://stackoverflow.com/questions/35727169/vue-js-use-variable-within-a-component-in-another-component。你應該剛剛更新你的原始問題。 – drneel