为了账号安全,请及时绑定邮箱和手机立即绑定

用V-for动态生成的radio,如何将当前选择的索引index传递给外部的方法?

用V-for动态生成的radio,如何将当前选择的索引index传递给外部的方法?

王小凯童鞋 2019-11-14 11:28:20
查看完整描述

2 回答

已采纳
?
一缕孤烟

TA贡献10条经验 获得超1个赞

<template>
    <div class="hello">
        <template v-for="(item,index) of list">
            <input type="radio" name="radio" :key="item" @click="radioClick(index)"/>
        </template>
    </div>
</template>
<script>
export default {
    name: 'HelloWorld',
    props: {msg: String},
    data(){
        return {
            list:[1,2,3]
        }
    },
    methods:{
        radioClick(index){
            console.log(index)
        }
    }
}
</script>

看看上面的代码是不是你想要的

查看完整回答
1 反对 回复 2019-11-14
  • 王小凯童鞋
    王小凯童鞋
    谢了兄弟,看的晚了,我已经用其他方法解决了,点个赞
?
一缕孤烟

TA贡献10条经验 获得超1个赞

能把,你现在的代码粘贴出来看看吗?不然不知道你指的外部方法是指什么?

查看完整回答
反对 回复 2019-11-14
  • 2 回答
  • 0 关注
  • 1081 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信