<p id="form-1">
<input type="checkbox" id="checkbox" v-model="toggle" :true-value='a' :false-value='b'>
<label for="checkbox">{{ toggle }}</label>
</p>
JS
new Vue({
el:'#form-1',
data:{
toggle:true,
a:'选了',
b:'没选'
}
})
Now I want this check box to be selected by default and the value is 'selected'. How should I write it?
给我你的怀抱2017-05-19 10:33:41
<input type="checkbox" id="checkbox" v-model="toggle">
<label for="checkbox">{{ toggle ? '选中' : '未选中' }}</label>
new Vue({
el: '#form-1',
data: {
toggle: true
}
})