无法在 laravel 5.8 中加载组件

failed to load component in laravel 5.8

我在 vue.js 中有以下 2 个组件并在 Laravel 5.8

中使用

这是app.js文件。

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'
});

下面是更改密码组件中的代码。

<template>
    <div>

    </div>
</template>

当我使用 npm run dev 构建代码时。

I get the below error: Failed to mount component: template or render function not defined in <ChangePassword> <Root>

当我从 app.js 中删除更改组件引用并使用 npm run dev 重新构建时,一切正常。

我错过了什么吗?

首先你的更改密码组件是空的,然后没有导出你的组件以供使用的导出默认脚本

它适用于此 Vue.component('change-password', require('./components/Account/changepassword.vue').default);

而不是这个:

Vue.component('change-password', require('./components/Account/changepassword.vue'));