我有一个web应用程序,前端是Vue.js,后端是Django。我想为每一行分配一个带有递增整数的名称,以区别表中的行,因此在后台,我可以循环一个整数范围,以便在表单提交后分别处理它们。
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<form id="myform" method="post" action="/tag_course/">
<table>
<thead>
...
</thead>
<tbody>
<tr v-for="(row, index) in Rows" :key="`isbn-${index}`">
<td :name="`title_${index}`" >{{ row.title }}</td>
<td :name="`discipline_code_course_code_${index}`" bgcolor= "white"><div contenteditable></div></td>
</tr>
</tbody>
</table>
<select id="semester" name="semester">
<option value="test">test</option>
</select>
</form>
</div>
<script>
var book_rows = [{title:1, author:1, edition:1}, {title:2, author:2, edition:2}, {title:3, author:3, edition:3}]
const app = new Vue({
el: '#app',
data:() => ({
filter: '',
rows: book_rows
}),
});
</script>
后端:
def check(request):
if request.method == 'POST':
print(request.POST) #here I only got semester value, but no
title and discipline_code_course_code related value
我有大约1000行,如何为不同行中的名称属性命名为Title_1、Title_2?
我尝试过:name="
title_${index}"
作为名称,但失败了。后端在后数据中没有这样的密钥
在后台,我只能获得正常的名称值(学期(,但无法使用:name="
规程_代码_课程_代码_${index}or
:name=";title_${index}
尝试使用以下
<td name="Title_{{index}}">{{ row.title }}</td>
或
<td :name="`Title_${index}`">{{ row.title }}</td>
如果我看对了,你已经在做你想要实现的事情了!Isbn和用作键的索引的组合与名称道具所需的组合相同。
所以你可以使用
<td :name="`title_${index}`">{{ row.title }}</td>
顺便说一句,最好使用";isbn";并将索引作为关键字。如果你拥有它,也许真正的是十亿,因为它是独一无二的。