In Vue.js, every component instance has its own isolated scope. So, you cannot directly reference parent data in a child component’s template.
Props are used to pass down data to the child components. Props are custom attributes. You can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance.
- Vue.component(‘blog-post’, {
- // camelCase in JavaScript
- props: [‘postTitle’],
- template: ‘<h3>{{ postTitle }}</h3>’
- })