简体   繁体   中英

Cannot copy props to data in child component in Vue

I have a child component SecondPage.vue . Props are passed to this component from parent component. Props are passed to child on click event. Then I'm trying to copy these props to data in SecondPage.vue . But when I use vue devtools, I can see, that data in child component is clear.

According to devtools, after click props in child are provided, but data ( genQ , isA ) is empty. Where is the mistake?

SecondPage.vue

export default {
    name: "SecondPage",
    props: ["generalQuestInfo", "isActive", "getIconClass"],
    data: function(){
        return {
            genQ: Object.assign({}, this.generalQuestInfo), //empty in devtools
            isA: this.isActive  //empty in devtools
        }
    }       
}

Vuex商店解决了我的问题!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM