|
|
@ -216,13 +216,13 @@ export function defineComputed ( |
|
|
|
if (typeof userDef === 'function') { |
|
|
|
sharedPropertyDefinition.get = shouldCache |
|
|
|
? createComputedGetter(key) |
|
|
|
: userDef |
|
|
|
: createGetterInvoker(userDef) |
|
|
|
sharedPropertyDefinition.set = noop |
|
|
|
} else { |
|
|
|
sharedPropertyDefinition.get = userDef.get |
|
|
|
? shouldCache && userDef.cache !== false |
|
|
|
? createComputedGetter(key) |
|
|
|
: userDef.get |
|
|
|
: createGetterInvoker(userDef.get) |
|
|
|
: noop |
|
|
|
sharedPropertyDefinition.set = userDef.set || noop |
|
|
|
} |
|
|
@ -253,6 +253,12 @@ function createComputedGetter (key) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function createGetterInvoker(fn) { |
|
|
|
return function computedGetter () { |
|
|
|
return fn.call(this, this) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function initMethods (vm: Component, methods: Object) { |
|
|
|
const props = vm.$options.props |
|
|
|
for (const key in methods) { |
|
|
|