I'm using laravel 5.4 and vue 2 and 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 default resolved (as showing) I don't know how should I pass the resolve and reject keys to this method in my page when I call the component.