25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Dynamic props<br />

We can reactively bind data to a component using the v-bind directive. When the<br />

data changes in the parent, it will automatically flow down to the child.<br />

In the following example, the value of title in the root instance gets<br />

programmatically updated after two seconds. This change will automatically<br />

flow down to MyComponent, which will reactively re-render to display the new<br />

value: <br />

<strong>Vue</strong>.component('my-component', { template: '{{ title }}', props: [<br />

'title' ] });<br />

var app = new <strong>Vue</strong>({ el: '#app', data: { title: 'Hello World' } });<br />

setTimeout(() => { app.title = 'Goodbye World' }, 2000); <br />

Since the v-bind directive is used so commonly in templates, you can<br />

omit the directive name as a shorth<strong>and</strong>: <br />

can be shortened to .

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!