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

Vue 专栏收录该内容
15 篇文章 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 <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

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值