我在 Laravel 中有一个大项目,它有几个前端,具体取决于登录用户。
我还有一个 shared
目录,不同的前端可以在其中使用常用组件(如表格、模态等)。
我想将每个前端编译成不同的js文件,所以我可以只包含每个用户的相关文件。
我现在所拥有的:
webpack.mix.js:
mix.js('resources/js/app.js', 'public/js')
.js('resources/js/frontendUser.js', 'public/js')
.js('resources/js/frontendAdmin.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
在 resources/js
下,我为每个前端都有一个单独的文件,例如 frontendAdmin.js
:
require('./bootstrap');
window.Vue = require('vue');
Vue.component(
'frontend-admin-component',
require('./components/FrontendAdminComponent.vue').default
);
const app = new Vue({
el: '#app',
});
当我运行 npm run dev
时,文件被正确编译,我可以从 blade 文件中包含它们:
<script src="{{ asset('js/frontendAdmin.js') }}" defer></script>
但是,我在控制台中遇到了这个错误:
[Vue warn]: Unknown custom element: <frontend-admin-component>
- did you register the component correctly? For recursive components,
make sure to provide the "name" option.
看起来该组件运行良好,但我认为该警告出于某种原因存在,并希望对其进行修复。
我尝试做的事情有意义吗?怎么了?
最佳答案
如果您没有为您的组件指定任何名称,通常会出现此警告
例如,如果您有一个名为 User.vue
的组件,那么您的组件应该如下所示:
<template>
</template>
<script>
export default {
name: 'User'
}
</script>
<style>
</style>
此名称选项不是强制性的,但惯例是为所有组件的每个组件使用一个名称。
https://stackoverflow.com/questions/56493065/
相关文章:
python - "pyenv virtualenvwrapper"是做什么的?
javascript - 简单的 react-spring 组件在 gatsby 中不起作用 - 元
typescript - Promise.resolve(null) 的目的是什么
javascript - 将 Uint8Array 转换为 Float32Array
c# - 使用 AddOpenIdConnect 时,为什么要添加默认范围?
angular - 我的 Angular 应用程序的规模(缩放)在生产中单独增加