W
W
WebDev2017-09-22 16:31:36
Vue.js
WebDev, 2017-09-22 16:31:36

How to get passed data in component method?

<my-component :post="post"></my-component>
I pass the post object to the component in this way.
How can I get this object in methods in the component? For example, in created?
UPD: I found them in this.$options.propsData.post, but maybe there is something more elegant?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-09-22
@kirill-93

Similar to the component's own data, they are available as instance properties:

props: [ 'post' ],
created() {
  console.log(this.post);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question