Vuejs: v-model array in multiple input

前端 未结 3 1022
一个人的身影
一个人的身影 2021-01-30 20:16

I have an input text field with a v-model attached, and every time someone hits the \"Add\" button, another input text get added to the DOM with the same v-model attached. I tho

3条回答
  •  感情败类
    2021-01-30 20:50

    If you were asking how to do it in vue2 and make options to insert and delete it, please, have a look an js fiddle

    new Vue({
      el: '#app',
      data: {
        finds: [] 
      },
      methods: {
        addFind: function () {
          this.finds.push({ value: 'def' });
        },
        deleteFind: function (index) {
          console.log(index);
          console.log(this.finds);
          this.finds.splice(index, 1);
        }
      }
    });
    
    

    Finds

    {{ $data }}

提交回复
热议问题