vue如何提交表格数据?

表格里有的数据是后台获取的,有的是需要在表单里输入的,表单绑定的v-model又是数组类型的v-model=inputArr[index],每一列表单的v-model又是不同的数组,那么最终要提交表格的数据,要怎么提交?是要拼接每一行的数据吗,还是有什么更好的办法?

https://img4.mukewang.com/5c67bbb00001767707810117.jpg

慕尼黑5688855
浏览 3743回答 1
1回答

达令说

html tr渲染用v-for<table class="table">&nbsp; <thead>&nbsp; <tr>&nbsp; &nbsp; <th>box</th>&nbsp; &nbsp; <th>new</th>&nbsp; &nbsp; <th>rank</th>&nbsp; &nbsp; <th>desc</th>&nbsp; &nbsp; <th>title</th>&nbsp; </tr>&nbsp; </thead>&nbsp; <tbody>&nbsp; <tr v-for="(v,i) in tabData">&nbsp; &nbsp; <td>{{v.box}}</td>&nbsp; &nbsp; <td>{{v.new}}</td>&nbsp; &nbsp; <td>{{v.rank}}</td>&nbsp; &nbsp; <td><input type="text" v-model="tabData[i]['desc']"></td>&nbsp; &nbsp; <td>{{v.title}}</td>&nbsp; </tr>&nbsp; </tbody></table><p>&nbsp; <button @click="submitTab" type="primary">提交</button></p>js 从后台获取的数据 tabDatatabData: [&nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; "box": 21650000,&nbsp; &nbsp; &nbsp; &nbsp; "new": true,&nbsp; &nbsp; &nbsp; &nbsp; "rank": 1,&nbsp; &nbsp; &nbsp; &nbsp; "title": "Geostorm"&nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; "box": 13300000,&nbsp; &nbsp; &nbsp; &nbsp; "new": true,&nbsp; &nbsp; &nbsp; &nbsp; "rank": 2,&nbsp; &nbsp; &nbsp; &nbsp; "title": "Happy Death Day"&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ]input框输入后submitTab触发后得到的tabData[&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; "box": 21650000,&nbsp; &nbsp; &nbsp; &nbsp; "new": true,&nbsp; &nbsp; &nbsp; &nbsp; "rank": 1,&nbsp; &nbsp; &nbsp; &nbsp; "title": "Geostorm",&nbsp; &nbsp; &nbsp; &nbsp; "desc": "123"&nbsp; &nbsp; },&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; "box": 13300000,&nbsp; &nbsp; &nbsp; &nbsp; "new": true,&nbsp; &nbsp; &nbsp; &nbsp; "rank": 2,&nbsp; &nbsp; &nbsp; &nbsp; "title": "Happy Death Day",&nbsp; &nbsp; &nbsp; &nbsp; "desc": "666"&nbsp; &nbsp; }]
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript