简体   繁体   中英

Accessing component properties in Vue

I am learning Vue and I have this simple component:

Vue.component('movie-tile', {
  props: ['movie'],
  data: function () {
    return {
      count: 0, 
    }
  },
  template: '<div>{{movie.Id}}</div>'
})

It works and the id is properly displayed but I get a warning:

[Vue warn]: Error in render: "TypeError: movie is undefined"

Now: when I change the template like this:

  template: '<div>{{movie}}</div>'

it works without a problem.

Any idea what's wrong?

movie在这里是您组件的属性,您应该尝试执行以下操作:

<movie-tile movie="{id : 10 , title : 'Harry Poter'}"></movie-tile>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM