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.

@click="clicked">`, props: [ 'dir' ], computed: { classes() { return 'carouselcontrol<br />

fa fa-2x fa-chevron-' + this.dir; } }, methods: { clicked() {<br />

this.$emit('change-image', this.dir === 'left' ? -1 : 1); } } } } } <br />

<br />

Now we can import this file into our app <strong>and</strong> register it locally in the root<br />

instance. As mentioned, <strong>Vue</strong> is able to automatically switch between kebab-case<br />

component names <strong>and</strong> Pascal-case ones. This means we can use the object<br />

shorth<strong>and</strong> syntax inside the component configuration <strong>and</strong> <strong>Vue</strong> will correctly resolve<br />

it.<br />

resources/assets/<strong>js</strong>/app.<strong>js</strong>: import ImageCarousel from<br />

'../components/ImageCarousel.vue';<br />

var app = new <strong>Vue</strong>({ ... components: { ImageCarousel<br />

} });<br />

Be sure to delete any remaining code from the original ImageCarousel component<br />

definition in app.<strong>js</strong> before moving on.

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

Saved successfully!

Ooh no, something went wrong!