你好,我有问题运行vue.js与laravel。我刚刚安装了新的laravel + vue,当我试图将示例组件添加到我的刀片时,什么也没有发生…我在控制台得到这个错误:
app.js:19073 Uncaught TypeError: Cannot read property 'component' of undefined
at Object../resources/js/app.js (app.js:19073)
表示这一行
Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue").default);
我的app. js是这样的
require('./bootstrap');
window.Vue = require('vue').default;
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
const app = new Vue({
el: '#app',
});
和在我的刀片我只是使用<example-component> </example-component>
标签。在js/components/ExampleComponent中确实是创建了一个示例组件。还有什么问题吗?
将app.js更改为解决的mz问题。可能laravel生成的默认app.js是针对Vue3的,而我使用的是Vue3
import { createApp } from 'vue';
require('./bootstrap');
let app=createApp({})
app.component('example-component', require('./components/ExampleComponent.vue').default);
app.mount("#app")