[Vuejs]-Vue.js – Cannot read property 'gameid' of undefined

0πŸ‘

βœ…

I’m guessing you have shortened your code, so I can only go by what you have written:

Firstly don’t mount to body, just create a div with an id and mount to that, secondly data needs to return an object inside a component:

data(){
   return {
      ready: null;
   }
}

You are also concatenating with the php syntax (dot) rather than a plus, so it should be:

'api/ready/games/' + this.gameid

And if gameid is a number you should pass it using v-bind:

<game v-bind:gameid="{{$gameid}}"></game>

Hopefully, that will get you someway to solving your problem, here’s a JSFiddle that seems to work fine:

https://jsfiddle.net/3h033p5q/

Leave a comment