如下图,Vue 抛:
[Vue warn]: Property or method "turn" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
(found in <Root>)
vue.js:634 [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined"
found in
---> <TopBar>
<Root>
warn @ vue.js:634
logError @ vue.js:1893
globalHandleError @ vue.js:1888
handleError @ vue.js:1848
Vue._render @ vue.js:3547
updateComponent @ vue.js:4061
get @ vue.js:4472
Watcher @ vue.js:4461
mountComponent @ vue.js:4068
Vue.$mount @ vue.js:9038
Vue.$mount @ vue.js:11923
init @ vue.js:3125
createComponent @ vue.js:5967
createElm @ vue.js:5914
createChildren @ vue.js:6042
createElm @ vue.js:5943
patch @ vue.js:6503
Vue._update @ vue.js:3940
updateComponent @ vue.js:4061
get @ vue.js:4472
Watcher @ vue.js:4461
mountComponent @ vue.js:4068
Vue.$mount @ vue.js:9038
Vue.$mount @ vue.js:11923
Vue._init @ vue.js:5006
Vue @ vue.js:5072
(anonymous) @ main.js:1
vue.js:1897 TypeError: Cannot read property '0' of undefined
at Proxy.eval (eval at createFunction (vue.js:11628), <anonymous>:3:143)
at VueComponent.Vue._render (vue.js:3545)
at VueComponent.updateComponent (vue.js:4061)
at Watcher.get (vue.js:4472)
at new Watcher (vue.js:4461)
at mountComponent (vue.js:4068)
at VueComponent.Vue.$mount (vue.js:9038)
at VueComponent.Vue.$mount (vue.js:11923)
at init (vue.js:3125)
at createComponent (vue.js:5967)
解决方法:
查看 Vue里的 data 是否赋值正确
new Vue({
name:'game',
el:'#app',
template: `<div id="#app">
<top-bar :turn="turn" :current-player-index="currentPlayerIndex" :players="players"/>
</div>`,
//如下未赋值,会抛上述错误
data: state,
});
乐意黎
2019-05-23