How can I get the value of a radio input and pass it to a function using @click in Vue.js. I actually want to do something like this:
<input type="radio" name="phone" :value="mobile.value" @click = "setPrice(value)">
What is the right syntax?
How can I get the value of a radio input and pass it to a function using @click in Vue.js. I actually want to do something like this:
<input type="radio" name="phone" :value="mobile.value" @click = "setPrice(value)">
What is the right syntax?
Share Improve this question asked Apr 22, 2018 at 16:59 Dhiaa Eddin AnabtawiDhiaa Eddin Anabtawi 391 silver badge8 bronze badges2 Answers
Reset to default 3For what your asking click here to see the answer
Checkout this straightforward example how input radio works with vue.js
<input type="radio" id="one" value="One" v-model="picked">
<label for="one">One</label>
<br>
<input type="radio" id="two" value="Two" v-model="picked">
<label for="two">Two</label>
<br>
and the script:
export default {
data: {
return {
picked: 'One'
}
}
}
Just provide the function name:
@click="setPrice"
You should then have access to the value:
function setPrice(event) {
const value = event.target.value;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744844897a4596773.html
评论列表(0条)