如何获取无线电输入的值并使用Vue.js中的@click将其传递给函数。我其实想做这样的事情:
<input type="radio" name="phone" :value="mobile.value" @click = "setPrice(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'
}
}
}
只需提供功能名称:
@click="setPrice"
然后,您应该有权访问该值:
function setPrice(event) {
const value = event.target.value;
}