原创

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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://aerchi.blog.csdn.net/article/details/90456908

如下图,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 个人打赏
文章最后发布于: 2019-05-23 00:23:54
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

打赏

打杂人

“你的鼓励将是我创作的最大动力”

5C币 10C币 20C币 50C币 100C币 200C币

分享到微信朋友圈

×

扫一扫,手机浏览