【发布时间】:2020-07-25 13:15:48
【问题描述】:
未捕获的类型错误:无法读取未定义的属性“推送”。我收到此错误。请帮我弄清楚我哪里出错了。我正在关注这个链接(https://jsbin.com/fikosoxuki/15/edit?html,js,output)
<template>
<v-card class="mb-12">
<v-form :model='user' class="content-padding" ref='pdfInputs'>
<ul>
<li v-for="(input, index) in user.inputs">
<input type="text" v-model="input.one"> - {{ input.one }}
<input type="text" v-model="input.two"> - {{ input.two }}
<button type="button" @click="deleteRow(index)">Delete</button>
</li>
</ul>
<button type="button" @click="addRow">Add more</button>
</v-form>
</v-card>
</template>
<script>
export default {
data () {
return {
user: {
inputs: []
}
}
}
methods: {
addRow() {
this.user.inputs.push({
one: '',
two: ''
})
},
deleteRow(index) {
this.user.inputs.splice(index,1)
}
}
}
</script>
更新(添加错误)
【问题讨论】:
-
你为什么不为你的代码做一个codepen链接?
-
-
如果它在 jsbin 中工作,有人会如何修复它?无论如何,尝试不同的浏览器。
-
@tony19 下数据{ }
-
数据设置在
data。代码没有问题
标签: javascript vue.js vuetify.js