報錯信息: You are binding v-model directly to a v-for iteration alias. This will not be able to modify the v-for source array because writing to the alias is like modifying a function local variable. Consider using an array of objects and use v-model on an object
數組
解釋:您正在將v-model直接綁定到v-for迭代別名。這將沒法修改v-for源數組,由於寫入別名相似於修改函數局部變量。考慮使用對象數組,而在對象屬性上使用v-model
ide
適用於此類結構:函數
{ 品牌: "米加亞", 顏色: "黑色系", CPU 核數: "八核", … }
解決方法:code
<div v-for="(value, name ,index) in object" :key="index"> <input v-model="value" /> <input v-model="object[name]" /> </div>