在 vue.js 中捕获无线电输入值

Capturing radio input value in vue.js

如何使用 Vue.js 中的@click 获取无线电输入的值并将其传递给函数。 我实际上想做这样的事情:

<input type="radio" name="phone" :value="mobile.value" @click = "setPrice(value)">

正确的语法是什么?

只需提供函数名称:

@click="setPrice"

然后您应该可以访问值:

function setPrice(event) {
  const value = event.target.value;
}

为了你的要求click here to see the answer

查看这个简单的示例,了解输入收音机如何与 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>

和脚本:

export default {
  data: {
    return {
      picked: 'One'
    }
  }
}