[Vuejs]-Vuejs use data from parent, but parent data usually update

0👍

You have to make sure you send file_data as a prop to your component. e.g. Your component is ‘myPopup’ and you should use it as below to send file_data as a prop:

<myPopup :myData="file_data" >

In this case, you can get file_data as ‘myData’ in the child component as below

After changes, your props should be:

props: {
    myData: {
        type: Object,
        default: () => {
            return {}
        }
    }
},

Your function should be:

Also, don’t forget to use ‘this’ keyword. this.myData instead of myData in function.

methods: {
    sendEmail() {
        let req_data = {};
        req_data['file'] = this.myData;
        
        // axios here
    };
},

Leave a comment