提供正确的代码,以便防止提交时默认浏览器刷新。
Also, provide code so that the input field values get a two-way binding to the Vue data instance properties 'itemName' and 'itemNumber'.
<form v-on:@(14)="addItem">
<p>Add item</p>
<p>
Item name:
<input type="text" required @(7)="itemName">
</p>
<p>
How many:
<input type="number" @(7)="itemNumber">
</p>
<button type="submit">Add item</button>
</form>
<form v-on:submit.prevent="addItem">
<p>Add item</p>
<p>
Item name:
<input type="text" required v-model="itemName">
</p>
<p>
How many:
<input type="number" v-model="itemNumber">
</p>
<button type="submit">Add item</button>
</form>