vue radio单选框,获取当前项的value值

1.给需要获取value值的单选框设置同一个点击事件
在方法里传入event当前事件对象

<template>
  <div>
    <label><input @click="getRadioVal" type="radio" name="type" value="全部">全部</label>
    <label><input @click="getRadioVal" type="radio" name="type" value="部分">部分</label>
    <label><input @click="getRadioVal" type="radio" name="type" value="零散">零散</label>
  </div>
</template>
<script>
export default {
  methods:{
    getRadioVal(event){ //event当前事件对象
        var radioVal = event.target.value;  
        console.log(radioVal)
    }
  }
}
</script>

2.点击每一项获得当前项的value值
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43233914/article/details/85237658