Reputation: 3630
I have a Vue component registered with:
Vue.component('logo', function (resolve) {require(['./components/layout/Logo.vue'], resolve)});
The component itself is defined as:
<template>
<div>
<div class="title">
<a href="/">
<h1>Welcome to my Site!</h1>
</a>
</div>
<navigation></navigation>
</div>
</template>
<style scoped>
h1 {
text-decoration: underline;
text-align: center;
color: #000000;
}
</style>
<script>
import Navigation from './Navigation.vue';
export default {
data() {
return {
msg:'hello vue'
}
},
components: {
Navigation
}
}
</script>
Logo.vue
and Navigation.vue
are in the same directory. Webpack does not complain when running.
When the site loads though there is a console error reported:
app.js:142 TypeError: Cannot read property 'call' of undefined
at __webpack_require__ (app.js:50)
at app.js:883
at <anonymous>
__webpack_require__.oe @ app.js:142
Promise rejected (async)
(anonymous) @ app.js:883
resolveAsyncComponent @ app.js:33890
createComponent @ app.js:35368
_createElement @ app.js:35578
createElement @ app.js:35517
vm._c @ app.js:35857
(anonymous) @ VM449:2
Vue._render @ app.js:35909
updateComponent @ app.js:34319
get @ app.js:34662
Watcher @ app.js:34651
mountComponent @ app.js:34323
Vue$3.$mount @ app.js:39644
Vue$3.$mount @ app.js:41847
Vue._init @ app.js:36017
Vue$3 @ app.js:36102
(anonymous) @ app.js:886
__webpack_require__ @ app.js:50
(anonymous) @ app.js:857
__webpack_require__ @ app.js:50
(anonymous) @ app.js:145
(anonymous) @ app.js:148
app.js:50 Uncaught (in promise) TypeError: Cannot read property 'call' of undefined
at __webpack_require__ (app.js:50)
at app.js:883
at <anonymous>
The same error occurs when I register the second component globally with Vue.component('navigation', function (resolve) {require(['./components/layout/Navigation.vue'], resolve)});
whether I use the component or not.
Upvotes: 1
Views: 245
Reputation: 3630
My webpack.mix.js
contained:
mix.webpackConfig({
output: {
filename: "js/[id].js"
}
});
After removing this I was able to load correctly. This was intended to move the outputted chunk files to the js/
directory, but was apparently wrong.
Upvotes: 1