Error in render: "TypeError: Cannot read property 'state' of undefined"

来源:8-10 Vue项目城市选择页 - Vuex的高级使用及localStorage

菜菜0123456

2021-07-12

我这里报了一个错,不知道为什么

[Vue warn]: Error in render: “TypeError: Cannot read property ‘state’ of undefined”

found in

—> at src/pages/Home/components/Header.vue
at src/pages/Home/Home.vue
at src/App.vue

warn @ vue.esm.js?efeb:628
logError @ vue.esm.js?efeb:1902
globalHandleError @ vue.esm.js?efeb:1897
handleError @ vue.esm.js?efeb:1857
Vue._render @ vue.esm.js?efeb:3580
updateComponent @ vue.esm.js?efeb:4090
get @ vue.esm.js?efeb:4504
Watcher @ vue.esm.js?efeb:4493
mountComponent @ vue.esm.js?efeb:4097
Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:9107 Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:12023
init @ vue.esm.js?efeb:3146
createComponent @ vue.esm.js?efeb:6033
createElm @ vue.esm.js?efeb:5980
createChildren @ vue.esm.js?efeb:6108
createElm @ vue.esm.js?efeb:6009
patch @ vue.esm.js?efeb:6532
Vue._update @ vue.esm.js?efeb:3969
updateComponent @ vue.esm.js?efeb:4090
get @ vue.esm.js?efeb:4504
Watcher @ vue.esm.js?efeb:4493
mountComponent @ vue.esm.js?efeb:4097
Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:9107 Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:12023
init @ vue.esm.js?efeb:3146
merged @ vue.esm.js?efeb:3331
createComponent @ vue.esm.js?efeb:6033
createElm @ vue.esm.js?efeb:5980
patch @ vue.esm.js?efeb:6532
Vue._update @ vue.esm.js?efeb:3969
updateComponent @ vue.esm.js?efeb:4090
get @ vue.esm.js?efeb:4504
Watcher @ vue.esm.js?efeb:4493
mountComponent @ vue.esm.js?efeb:4097
Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:9107 Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:12023
init @ vue.esm.js?efeb:3146
createComponent @ vue.esm.js?efeb:6033
createElm @ vue.esm.js?efeb:5980
createChildren @ vue.esm.js?efeb:6108
createElm @ vue.esm.js?efeb:6009
patch @ vue.esm.js?efeb:6532
Vue._update @ vue.esm.js?efeb:3969
updateComponent @ vue.esm.js?efeb:4090
get @ vue.esm.js?efeb:4504
Watcher @ vue.esm.js?efeb:4493
mountComponent @ vue.esm.js?efeb:4097
Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:9107 Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:12023
init @ vue.esm.js?efeb:3146
createComponent @ vue.esm.js?efeb:6033
createElm @ vue.esm.js?efeb:5980
patch @ vue.esm.js?efeb:6571
Vue._update @ vue.esm.js?efeb:3969
updateComponent @ vue.esm.js?efeb:4090
get @ vue.esm.js?efeb:4504
Watcher @ vue.esm.js?efeb:4493
mountComponent @ vue.esm.js?efeb:4097
Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:9107 Vue.mount@vue.esm.js?efeb:9107Vue.mount @ vue.esm.js?efeb:12023
Vue._init @ vue.esm.js?efeb:5041
Vue @ vue.esm.js?efeb:5108
eval @ main.js?1c90:18
./src/main.js @ app.js:2033
webpack_require @ app.js:679
fn @ app.js:89
0 @ app.js:2162
webpack_require @ app.js:679
(匿名) @ app.js:725
(匿名) @ app.js:728
Show 40 more frames
vue.esm.js?efeb:1906 TypeError: Cannot read property ‘state’ of undefined
at VueComponent.mappedState (vuex.esm.js?b949:945)
at Watcher.get (vue.esm.js?efeb:4504)
at Watcher.evaluate (vue.esm.js?efeb:4606)
at VueComponent.computedGetter [as city] (vue.esm.js?efeb:4860)
at Object.get (vue.esm.js?efeb:2113)
at Proxy.render (eval at ./node_modules/vue-loader/lib/template-compiler/index.js?{“id”:“data-v-1a2e1f3a”,“hasScoped”:true,“transformToRequire”:{“video”:[“src”,“poster”],“source”:“src”,“img”:“src”,“image”:“xlink:href”},“buble”:{“transforms”:{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/pages/Home/components/Header.vue (app.js:1708), :15:49)
at VueComponent.Vue._render (vue.esm.js?efeb:3578)
at VueComponent.updateComponent (vue.esm.js?efeb:4090)
at Watcher.get (vue.esm.js?efeb:4504)
at new Watcher (vue.esm.js?

写回答

1回答

Dell

2021-07-15

/Header.vue 代码发出来看下

0
0

Vue2.5-2.6-3.0开发去哪儿网App 零基础入门到实战

课程紧跟Vue3版本迭代,企业主流版本Vue2+Vue3全掌握

10675 学习 · 8191 问题

查看课程