问题
I have below 2 components in vue.js and using in Laravel 5.8
Here is app.js file.
require('./bootstrap');
import VeeValidate from 'vee-validate';
window.Vue = require('vue');
Vue.use(VeeValidate);
Vue.component('profile', require('./components/Account/Profile.vue').default);
Vue.component('change-password', require('./components/Account/changepassword.vue'));
const app = new Vue({
el: '#app'
});
Below is the code in change password component.
<template>
<div>
</div>
</template>
When I build the code using npm run dev
.
I get the below error: Failed to mount component: template or render function not defined in
<ChangePassword> <Root>
When I remove the change component reference from app.js and re build using npm run dev
then everthing work.
Am I missing anything?
回答1:
First your change password component is empty and then there is no export default script that exports your component for use
回答2:
It worked with this Vue.component('change-password', require('./components/Account/changepassword.vue').default);
Instead of this:
Vue.component('change-password', require('./components/Account/changepassword.vue'));
来源:https://stackoverflow.com/questions/55801209/failed-to-load-component-in-laravel-5-8