1.错误做法,添加进的所有数据会一模一样

<input v-model="newItem.question"/>
data () {
    return {
      questionlist: [],
      newItem: {
        question: '',
        items: ['不愿意参加', '配合参加', '即使只要']
      }
    }
  }
methods: {
  add () {
      this.questionlist.push(this.newItem)
  }
}

2.正确做法

<input v-model="newQuestion"/>
data () {
    return {
      questionlist: [],
      newQuestion: '',
      newItems: ['不愿意参加', '配合参加', '即使只要']
    }
}
add () {
    var obj = {}
    obj.question = this.newQuestion
    obj.items = this.newItems
    this.questionlist.push(obj)
}
作者 铁血 汉子 2018年5月20日
2024/04/30/02:29:49am 2018/5/20/9:07:00
0 11650