added modal component use parent methods and data

This commit is contained in:
Cihan Şentürk 2023-03-01 14:54:25 +03:00 committed by GitHub
parent 8a0d02d0a0
commit 8264b236ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -198,9 +198,25 @@ export default {
masked: false /* doesn't work with directive */
};
// Parent vue instance methods merge with child vue instance methods
if (this.$root.$options.methods) {
for (let method in this.$root.$options.methods) {
this[method] = this.$options.methods[method] !== undefined ? this.$options.methods[method] : this.$root.$options.methods[method];
let parent_methods = this.$root.$options.methods;
for (let method_key in parent_methods) {
if (this.$options.methods[method_key] === undefined) {
this[method_key] = parent_methods[method_key];
}
}
}
// Parent vue instance data merge with child vue instance data
if (this.$root._data) {
let parent_data = this.$root._data;
for (let data_key in parent_data) {
if (this[data_key] === undefined) {
this[data_key] = parent_data[data_key];
}
}
}
},