[Vuejs]-Vue TypeError: Cannot read property '_wrapper' of undefined

1๐Ÿ‘

โœ…

  • data in Vuejs is a function that returns an object. Your code is not returning an object.
  • Your prop name is same the data name. They should be different.

Try the following code:

[...some layout...]
       <a @click="addElement" id="addBtn">Add</a>
    </span>
  </div>
</template>

<script>
  export default {
      props: [
          'routes'
      ],
      data: function () {
         return {         // Object being returned
             storedRoutes: this.routes   // props can be directly accessed using `this`
         }
      },
      methods: {
          addElement: function () {
              this.storedRoutes.push( {[...some object...]} );
          }
      }
  }
</script>

I also changed this.props.routes to this.routes

๐Ÿ‘คAnkit Kante

Leave a comment