I have created a modal box component and passing data to it using props. in this component I want to catch this props data into a vue data()
method only when the modal is opened(showed). How can I do that?
One method I did which worked is using updated()
event like below code but realized it runs globally an not just on component update.
export default {
props: ['widget_data'],
data() {
return {
new_data: {},
}
},
methods: {
hideMe() {
this.$emit('closeClicked')
},
saveMe() {
this.$emit('saveClicked')
},
},
updated() {
this.new_data = this.widget_data
},
}
updated()
runs globally" but you could also try adding a watcher forwidget_data
?