关于前端:从后台传回许多input再传回给后台input变成数组应可以这样写

 <table width="100%" border="1" cellspacing="0" cellpadding="0" v-for="item in questions"
                   :key="item.id">
                <tr>
                    <td colspan="3" v-if="item.id==2">{{item.name}}</td>
                </tr>
                <tr v-for="(itemC,index) in item.content" :key="itemC.id">
                    <td>{{itemC.textID}}</td>
                    <td>{{itemC.text}}</td>
                    <td>
                        <el-radio-group v-model="radio[index]" prop="Content" v-if="itemC.id==11||itemC.id==27">
                            <el-radio :label="check.id" :key="check.id" v-for="check in itemC.check">{{check.text}}
                            </el-radio>
                        </el-radio-group>
                        <input v-else type="text" v-model="responed[index]"/>
                    </td>
                </tr>
            </table>

从后盾传回许多input,再传回给后盾,input变成数组应该怎么写,不能写成v-model=”responed”,因为responed为字符串,每次批改只会变成另外一个值,之前的值会被笼罩,须要写成v-model=”responed[index]”,responed定义为数组,index为下层for循环的index, v-for=”(itemC,index) in item.content”,我的业务要求有input和radio,不须要写radio的能够不看那块代码,radio与input用法统一

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理