我最近在mac上创建了一个Laravel 9项目。我正在尝试在我的项目中使用Vue组件。Laravel安装附带一个Vue组件(js/Components/ExampleComponenets.vue)。我在视图文件中包含了example-component,页面正确地显示了组件。
我将该组件复制为js/Component.vue,并更新了app.js,将新组件注册为“note Component.vue”。
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
Vue.component('note-component', require('./components/NoteComponent.vue').default);但是,当我在视图文件中使用note-component时,它会显示错误:
[Vue warn]: Unknown custom element: <note-component> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)我从视图文件中删除了note组件,并对ExampleComponent.vue中使用的ExampleComponent.vue进行了更改,但令人惊讶的是,页面继续显示旧消息。我得到的印象是,应用程序继续使用旧的js文件,我需要对js文件进行处理。(php手工清除:缓存)没有帮助。
有人能告诉我如何解决这个问题吗?
谢谢。
发布于 2022-04-05 19:04:17
您需要使用npm来启动vue服务器,并且要记住,当页存储在浏览器内存中时,js是加载的,所以要执行完整的重新加载。
发布于 2022-04-05 20:41:35
我们最近更新到Laravel到v9,并且不得不以这样的方式修改js文件:
import Vue from "vue";
Vue.component("example", () => import("./components/ExampleComponent"));来源:Vue template or render function not defined yet I am using neither?
https://stackoverflow.com/questions/71756740
复制相似问题