【发布时间】:2018-01-16 13:00:54
【问题描述】:
我有一个注册的 Vue 组件:
Vue.component('logo', function (resolve) {require(['./components/layout/Logo.vue'], resolve)});
组件本身定义为:
<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 和 Navigation.vue 在同一目录中。 Webpack 运行时不会报错。
当网站加载但报告控制台错误时:
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>
当我用Vue.component('navigation', function (resolve) {require(['./components/layout/Navigation.vue'], resolve)});全局注册第二个组件时,无论我是否使用该组件,都会出现同样的错误。
【问题讨论】:
标签: javascript laravel vue.js vue-component