2017-08-14 37 views
0

我有这个代码到目前为止,我尝试从单选按钮的值。我可以从V模型的价值,但与无线电我有一些问题。例如,如果我有更多的单选按钮,我可以采取检查一个。如何在vuejs中检查电台值?

new Vue({ 
el:'#root', 
data:{ 
    removelines: [ 
    {value:'a'}, 
    {value:'b'} 
    ] 

}, 

methods:{ 
insert:function(){ 
    let vueIn = this; 

    axios.post('/vue', {removelines: vueIn.removelines.value}).then(
     function(response){ 
     vueIn.removelines = response.data.removelines.value; 
     } 
    ).catch(function(error){ console.log(error.message); }); 
    } 
} 

}); 

HTML代码在这里:

<div class="card-block"> 
    <div class="btn-group" data-toggle="buttons"> 
     <label class="btn btn-warning active"> 
      <input v-model="removelines" name="removelines" type="radio" class ="cheker" autocomplete="off" v-bind:value="a" checked> 
      Yes 
     </label> 
     <label class="btn btn-warning"> 
      <input v-model="removelines" name="removelines" type="radio" class ="cheker" v-bind:value="b"> 
      No 
     </label> 
    </div> 
</div> 

回答

1

检查这方面的工作样本,请。

new Vue({ 
 
    el: '#root', 
 
    data: { 
 
    removelines: 'b' 
 
    } 
 
});
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script> 
 
<div id="root"> 
 
<div class="card-block"> 
 
    {{ removelines }} 
 
    <div class="btn-group" data-toggle="buttons"> 
 
     <label class="btn btn-warning active"> 
 
      <input v-model="removelines" name="removelines" type="radio" class ="cheker" autocomplete="off" v-bind:value="'a'" checked> 
 
      Yes 
 
     </label> 
 
     <label class="btn btn-warning"> 
 
      <input v-model="removelines" name="removelines" type="radio" class ="cheker" v-bind:value="'b'"> 
 
      No 
 
     </label> 
 
    </div> 
 
</div> 
 
</div>

+0

我看到它的工作,你可以用爱可信发布最新动态? –

+0

@AdrianKlark我不知道你的方法正在使用什么和你正在使用的端点,我找不到'insert'方法和你的问题之间的关系。你能否更新你的问题描述? – choasia

+0

谢谢我修改它的接缝bootstrap js与其他js有冲突 –