fix(computed): support arrow function usage for computed option
fix #733
This commit is contained in:
@@ -52,9 +52,7 @@ describe('api: options', () => {
|
||||
bar(): number {
|
||||
return this.foo + 1
|
||||
},
|
||||
baz(): number {
|
||||
return this.bar + 1
|
||||
}
|
||||
baz: (vm): number => vm.bar + 1
|
||||
},
|
||||
render() {
|
||||
return h(
|
||||
|
||||
@@ -302,12 +302,12 @@ export function applyOptions(
|
||||
__DEV__ && checkDuplicateProperties!(OptionTypes.COMPUTED, key)
|
||||
|
||||
if (isFunction(opt)) {
|
||||
renderContext[key] = computed(opt.bind(ctx))
|
||||
renderContext[key] = computed(opt.bind(ctx, ctx))
|
||||
} else {
|
||||
const { get, set } = opt
|
||||
if (isFunction(get)) {
|
||||
renderContext[key] = computed({
|
||||
get: get.bind(ctx),
|
||||
get: get.bind(ctx, ctx),
|
||||
set: isFunction(set)
|
||||
? set.bind(ctx)
|
||||
: __DEV__
|
||||
|
||||
Reference in New Issue
Block a user