[Vuejs]-Unable to display component on screen

0👍

Your code should work fine if getCorpora has been updated/reactive. I just created a demo, Can you please have a look and try to find the root cause of the issue you are facing.

Demo (I just added an input and on blur, input value has been added into a getCorpora array) :

Vue.component('corpus', {
  props: ['childmsg'],
  template: '<p>{{ childmsg }}</p>'
});

var app = new Vue({
  el: '#app',
  data: {
    corpus: '',
    getCorpora: [{
        id: 1,
      name: 'Corpus A' 
    }, {
        id: 2,
      name: 'Corpus B' 
    }, {
        id: 3,
      name: 'Corpus C' 
    }]
  },
  methods: {
    addCorpus() {
      if (this.corpus) {
        const index = this.getCorpora.at(-1).id + 1
            this.getCorpora.push({
            id: index,
          name: this.corpus
        })
      }
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  Add corpus : <input type="text" v-model="corpus" @blur="addCorpus">
  <div v-for="corpus in getCorpora" v-bind:key="corpus.id">
    <Corpus :childmsg="corpus.name"></Corpus>
  </div>
</div>

Leave a comment