Merge pull request #2913 from CihanSenturk/added-modal-component-use-parent-methods-and-data

Added modal component use parent methods and data
This commit is contained in:
Cüneyt Şentürk 2023-03-01 17:17:40 +03:00 committed by GitHub
commit f46bd7f1ac
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];
}
}
}
},