Исправление потенциальных багов при использовании ООП
This commit is contained in:
@@ -35,15 +35,19 @@ export default function(componentClass) {
|
|||||||
for (const method of classMethods) {
|
for (const method of classMethods) {
|
||||||
const desc = Object.getOwnPropertyDescriptor(classProto, method);
|
const desc = Object.getOwnPropertyDescriptor(classProto, method);
|
||||||
if (desc.get) {//has getter, computed
|
if (desc.get) {//has getter, computed
|
||||||
computed[method] = {get: desc.get};
|
if (!computed[method]) {
|
||||||
if (desc.set)
|
computed[method] = {get: desc.get};
|
||||||
computed[method].set = desc.set;
|
if (desc.set)
|
||||||
} else if ( ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'activated',//life cycle hooks
|
computed[method].set = desc.set;
|
||||||
'deactivated', 'beforeUnmount', 'unmounted', 'errorCaptured', 'renderTracked', 'renderTriggered',//life cycle hooks
|
}
|
||||||
'setup'].includes(method) ) {
|
} else if ( ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'activated',
|
||||||
comp[method] = obj[method];
|
'deactivated', 'beforeUnmount', 'unmounted', 'errorCaptured', 'renderTracked', 'renderTriggered',
|
||||||
|
'setup'].includes(method) ) {//life cycle hooks
|
||||||
|
if (!comp[method])
|
||||||
|
comp[method] = obj[method];
|
||||||
} else if (method !== 'constructor') {//usual
|
} else if (method !== 'constructor') {//usual
|
||||||
methods[method] = obj[method];
|
if (!methods[method])
|
||||||
|
methods[method] = obj[method];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user