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

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

2.正确做法

  1. <input v-model="newQuestion"/>
  1. data () {
  2. return {
  3. questionlist: [],
  4. newQuestion: '',
  5. newItems: ['不愿意参加', '配合参加', '即使只要']
  6. }
  7. }
  1. add () {
  2. var obj = {}
  3. obj.question = this.newQuestion
  4. obj.items = this.newItems
  5. this.questionlist.push(obj)
  6. }
作者 铁血 汉子 2018年5月20日
2025/07/03/06:06:25pm 2018/5/20/9:07:00
0 12291