在Vue中,等效于使用vanilla javascript从按钮中取消选择单选按钮

在Vue中,等效于使用vanilla javascript从按钮中取消选择单选按钮,javascript,vue.js,Javascript,Vue.js,我在普通javascript中有以下代码: const radio = document.querySelector('#radio'); const boton = document.querySelector('#boton'); boton.addEventListener('click', () => { radio.checked = false; }); 使用vue的正确方法是什么 这是我在Vue模板中的代码: <tr v-for="(flt, f) in

我在普通javascript中有以下代码:

const radio = document.querySelector('#radio');
const boton = document.querySelector('#boton');

boton.addEventListener('click', () => {
radio.checked = false;
});
使用vue的正确方法是什么

这是我在Vue模板中的代码:

<tr v-for="(flt, f) in filterResponse" :key="f">   
<td>
    <input type="radio" 
    @change="someMethod()" 
    :id="f" 
    :checked="false">
</td>

我不知道的是如何从一个方法访问无线电输入的id,或者是否有其他方法。谢谢

我不知道你的filterResponse是什么样子,但如果你的filterResponse包含对象,那么你可以向每个对象添加选中项,并可以轻松切换它

     <tr v-for="(flt, f) in filterResponse" :key="f">
        <td>
            <input type="radio" 
            @change="someMethod()" 
            :id="f"
            :checked="flt.checked">
        </td>
        <td>
            <button @click="flt.checked = !flt.checked">Uncheck</button>
        </td>
    </tr>

如果单击按钮时只希望为false,则替换
!flt.用
false检查

我使用querySelector从方法中解决了半径id问题:

const confirmed = document.querySelector(`#rbConfirmed${this.radioId}`);
confirmed.checked = false;
     <tr v-for="(flt, f) in filterResponse" :key="f">
        <td>
            <input type="radio" 
            @change="someMethod()" 
            :id="f"
            :checked="flt.checked">
        </td>
        <td>
            <button @click="flt.checked = !flt.checked">Uncheck</button>
        </td>
    </tr>
        filterResponse: [
            {value: 1, checked: true}, 
            {value: 2, checked: true}, 
        ]
const confirmed = document.querySelector(`#rbConfirmed${this.radioId}`);
confirmed.checked = false;