2017-11-28 6 views
0

VueJS 응용 프로그램을 만들고 있습니다. 부모로부터 데이터가 전달되는 Child 구성 요소 Child.vue가 있습니다.[Vue 경고] : 생성 된 후크 오류 : "TypeError : 정의되지 않은 속성을 설정할 수 없습니다"

Child.vue

그리고 내 부모 구성 요소는 다음과 같습니다

export default{ 
 

 
    props:['info'], 
 

 
    data: function(){ 
 
     return{ 
 
      timeValue:{ 
 
       minutes: '', 
 
       hours: '' 
 
      } 
 
     } 
 
    }, 
 
    created: function(){ 
 
     
 
     console.log("Printing inside created of Child ",this.info); 
 
     this.convertMins(this.info[0][2]); 
 
     
 
    }, 
 

 
    methods:{ 
 
     convertMins: (minutes) => { 
 
      console.log("Printing inside convert mins", this); 
 
      if(minutes===0){ 
 
       this.timeValue.minutes = 0; 
 
       this.timeValue.hours = 0; 
 
      } 
 
      if(minutes===60){ 
 
       this.timeValue.hours = 1; 
 
       this.timeValue.minutes = 0; 
 
      } 
 
      if(minutes>60){ 
 
       this.timeValue.hours = Math.floor(minutes/60); 
 
       this.timeValue.minutes = minutes % 60; 
 
      } 
 
     } 
 
    } 
 

 
}
,

Parent.vue

import Child from './Child.vue'; 
 

 
export default { 
 
data(){ 
 
\t return{ 
 
     info:[ ], 
 

 
     errors: [] 
 
\t } 
 
}, 
 

 
created: function(){ 
 

 
    this.accessInformation(); 
 
}, 
 

 
methods: { 
 
    
 
    accessInformation: function(){ 
 
    axios.get(localhost:3000/retrieveInfo) 
 
    .then(response =>{ 
 
    console.log(response.data.rows[3]); 
 
    this.info.push(response.data.rows[3]); 
 
    }) 
 
    .catch(e => { 
 
      this.errors.push(e); 
 
    }) 
 
} 
 
}, 
 

 
components: { \t \t \t \t \t \t \t \t 
 
    'child': Child, 
 
    
 
    } 
 
}
<template> 
 
<div> 
 
    <child v-bind:info="info" v-if="info.length > 0"></child> 
 
</div> 
 
</template>
왜이 오류를 얻고있다

Error

enter image description here

313,210

내가 응용 프로그램을 실행 해보십시오, 나는이 같은 오류가? 나는 VueJS에 처음 온 사람입니다. 누군가 나를 좀 도와 주실 수 있습니까?

답변

1

this에서 경고 상자를 참조하십시오.

convertMins: (minutes) => {} 대신 convertMins(minutes) {}을 사용하십시오.