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

王小凯童鞋
浏览 1091回答 2
2回答

一缕孤烟

<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>看看上面的代码是不是你想要的

一缕孤烟

能把,你现在的代码粘贴出来看看吗?不然不知道你指的外部方法是指什么?
打开App,查看更多内容
随时随地看视频慕课网APP