failed to load component in laravel 5.8

a 夏天 提交于 2019-12-13 03:16:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!