2017-11-10 4 views
1

기본 개체를 포함하는 구성 요소가 있고 생성시 채워진 개체가 생깁니다. this.profile을 새로운 객체에 바인드하려고 할 때 메소드에서 올바른 데이터를 얻는 것처럼 보이지만 변경 사항은 this.profile의 다른 용도로 푸시되지 않습니다. 스크립트의 나머지 부분에서이 변경 사항을 강제 적용 할 수있는 방법이 있습니까?Gue 뒤에 Vue.js 구성 요소 데이터가 업데이트되지 않습니다.

export default { 
data() { 
    return { 
     profile: { 
      firstName: 'Seller First Name', 
      surname: 'Seller Surname', 
      username: '', 
      biography: 'Seller biography.', 
      phoneNumber: 'Seller Phone Number', 
      emailAddress: 'Seller Email', 
      profilePhotoUrl: '', 
      testimonials: [] 
     } 
    }; 
}, 

components: { 
    ProfileSummary, 
    Biography, 
    TestimonialList, 
    PaymentsenseCompany 
}, 

created() { 
    console.log('created'); 
    this.getProfile(this.$route.params.sellerUsername); 
}, 

methods: { 
    getProfile(sellerUsername) { 
     axios.get('http://fieldsellerprofileapi.azurewebsites.net/api/fieldseller/' + sellerUsername) 
     .then(function(response) { 
      this.profile = Object.assign({}, response.data); 
      Vue.nextTick(() => { 
       console.log('after', this); 
      }); 
     }.bind(this)) 
     .catch(e => { 
      console.log(e); 
      // location.replace('/404'); 
     }); 
    } 
}, 

답변

0

는 그래서 문제가 값이 업데이트되지 있다고 아니었다 밝혀졌습니다. 그들은 잘 저장되었다. 나는 부모와 함께 어떤 이유로 업데이트되지 않은 자식 구성 요소에 액세스하려고 시도하고 있었다. 변화는 아이들에게 전파되지 않았습니다 ... 이것은 동일한 문제가있는 경우 연구를 위해 유용 할 수 있습니다.

감사합니다.

1

임 확실하지 않은,하지만이 시도 :

getProfile(sellerUsername) { 
    axios 
    .get('http://fieldsellerprofileapi.azurewebsites.net/api/fieldseller/' + sellerUsername) 
    .then(r => this.profile = r.data) 
    .catch(e => console.log(e)) 
} 
관련 문제