2017-08-14 4 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

私はあなたがaxiosポストを更新することができ、それが働いている参照してください? –

+0

@AdrianKlarkどのメソッドが使用されているのか、使用しているエンドポイントがわからないので、 'insert'メソッドとあなたの質問との関係を見つけることができません。質問の説明を更新してください。 – choasia

+0

ありがとう私はそれを変更する継ぎ目のブートストラップjsは他のjsと競合している –

関連する問題