Vue抛 Property or method "turn" is not defined on the instance but referenced during render. 的解决方法

灰太狼 2022-01-28 01:51 426阅读 0赞

如下图,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 )

vue.js:634 [Vue warn]: Error in render: “TypeError: Cannot read property ‘0’ of undefined”

found in

-—>

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), :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 是否赋值正确

  1. new Vue({
  2. name:'game',
  3. el:'#app',
  4. template: `<div id="#app">
  5. <top-bar :turn="turn" :current-player-index="currentPlayerIndex" :players="players"/>
  6. </div>`,
  7. //如下未赋值,会抛上述错误
  8. data: state,
  9. });

乐意黎

2019-05-23

发表评论

表情:
评论列表 (有 0 条评论,426人围观)

还没有评论,来说两句吧...

相关阅读