刚刚开始学习vue.js,在下面的例子中,如何解决v-for div中重复无线电值的问题?
https://jsfiddle.net/794xkk97/3/
if ( not exists $hashtime{ $arr[0] } ) {
$hashtime{ $arr[0] } = ( $date => { $hour => { $min => [ $sec ] } } );
$create++;
print "create for IP: $arr[0]\n";
}
if ( not exists $hashtime{ $arr[0] }{$date} ) {
$hashtime{ $arr[0] }{ $date } = ( $hour => { $min => [ $sec ] } );
$create++;
print "create for IP: $arr[0] DATE: $date\n";
}
if ( not exists $hashtime{ $arr[0] }{$date}{$hour} ) {
$hashtime{ $arr[0] }{ $date }{ $hour } = ( $min => [$sec] );
$create++;
print "create for IP: $arr[0] DATE: $date HOUR: $hour\n";
}
答案 0 :(得分:1)
因此,如果我理解正确的话,那么问题就是你所有的单选按钮绑定到同一个项目的v模型,这将导致重复结果。请查看链接https://jsfiddle.net/794xkk97/4/。 (另一种解决方案是制作自己的vue-radio按钮)
调整后备箱项目:
trunk: [{
question: 'sub question1',
id: 'group1'
}, {
question: 'sub question2',
id: 'group2'
}, {
question: 'sub question3',
id: 'group3'
}],
调整已检查的数据项:
checked: {
group1: '',
group2: '',
group3: ''
},
和v-loop:
<div v-for="itemT in trunk">
{{ itemT.question }}
<ul>
<li v-for="item in selections">
<input type="radio" v-model="checked[itemT.id]" :value="item.val">{{ item.txt }}
</li>
</ul>
<p>{{ checked[itemT.id] }}</p>
</div>