I can't seem to make Vue components work on my Laravel 5.4 installation.
I register my components in resources/assets/js/app.js
Vue.component(
'box',
require('./components/Box.vue')
);
I also register Laravel Passport's vue components in the same file:resources/assets/js/app.js
And in resources/assets/js/components/Box.vue
<template>
<div class="box box-solid box-primary">
<div class="box-header">
<h3 class="box-title">{{ title }}</h3>
</div>
<div class="box-body">
<slot></slot>
</div>
</div>
</template>
<script>
export default {
props: ['title'],
data() {
return {
title: 'Box Title'
}
}
}
</script>
Then I run npm run dev to compile my code to public/js/app.js which is then 'registered' in a master layout's <head>.
And when I try to use it in a view:
<div id="app">
<box title="This is my Box">
<h1>I'm inside this box</h1>
</box>
</div>
const vm = new Vue({
el: "#app"
});
I get the following message: 'Did you register the component correctly?'
It all works when I register the component in the same .js file where I put the const vm = new Vue({ /*...*/ }).
I also check the output public/js/app.js and I see that my component is being 'registered'
Do I need to do something else to make it work or am I doing all this in a wrong way?