I'm using Laravel 5.4 and Vue.js 2. I want to load a component as async using a button. My Vue.js components are separate: example.vue and test.vue, and I load them as an HTML tag.
This is my app.js:
import './bootstrap';
import example from './components/Example.vue';
Vue.component('example', example);
const app = new Vue({
el: '#app'
});
This is the place to show components:
<How can I use Async components?div id="app">
<example2></example2>
</div>
How can I use async components?
No, I think you don't understand me. It's my component registration:
import './bootstrap';
import example from './components/Example.vue';
Vue.component('example', example);
Vue.component('example2', function (resolve) {
require(['./components/Example2.vue'],resolve)
})
const app = new Vue({
el: '#app'
});
And in require, it defaults to resolved (as showing). I don't know how I should pass the resolve and reject keys to this method in my page when I call the component.