Using v-for in a v-model, vuetify 3 在 vuetify 3 中使用 v-for 在 v-model 中

huangapple go评论56阅读模式
英文:

Using v-for in a v-model, vuetify 3

问题

我不会再回答这个问题。

英文:

I have a v-for rendering trought input fields from the user and keep getting the same error. Somehow my property .begin from the element of the array is getting undefined

I just keep receiving the same error : Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'begin')

Thats my templateenter image description here.

And that is my Scriptenter image description here

答案1

得分: 0

在第43行的HAcademico: [this.OneActivity, this.OneActivity]中,您正在使用this关键字来引用同一个对象,但是this引用的是data()上下文,所以您需要这样做:

data() {
    const oneActivity = {begin: '', end: '', type: '', text: ''}

    return {
        oneActivity,
        HAcademico: [oneActivity, oneActivity],
    }
}
英文:

in HAcademico: [this.OneActivity, this.OneActivity] in line 43, you are using this keyword to refer to same object, but this refers to data() context, so you need to do this:

data() {
	const oneActivity = {begin: '', end: '', type: '', text: ''}

	return {
		oneActivity,
		HAcademico: [oneActivity, oneActivity],
	}
}

huangapple
  • 本文由 发表于 2023年5月24日 23:32:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76325185.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定