javascript - Capturing radio input value in vue.js - Stack Overflow

How can I get the value of a radio input and pass it to a function using @click in Vue.js. I actually

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 badges
Add a ment  | 

2 Answers 2

Reset to default 3

For 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

相关推荐

  • javascript - Capturing radio input value in vue.js - Stack Overflow

    How can I get the value of a radio input and pass it to a function using @click in Vue.js. I actually

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信