fix(watch): this.$watch should support watching keypath
This commit is contained in:
@@ -20,7 +20,12 @@ import {
|
||||
isPromise
|
||||
} from '@vue/shared'
|
||||
import { computed } from './apiComputed'
|
||||
import { watch, WatchOptions, WatchCallback } from './apiWatch'
|
||||
import {
|
||||
watch,
|
||||
WatchOptions,
|
||||
WatchCallback,
|
||||
createPathGetter
|
||||
} from './apiWatch'
|
||||
import { provide, inject } from './apiInject'
|
||||
import {
|
||||
onBeforeMount,
|
||||
@@ -939,17 +944,6 @@ function createWatcher(
|
||||
}
|
||||
}
|
||||
|
||||
function createPathGetter(ctx: any, path: string) {
|
||||
const segments = path.split('.')
|
||||
return () => {
|
||||
let cur = ctx
|
||||
for (let i = 0; i < segments.length && cur; i++) {
|
||||
cur = cur[segments[i]]
|
||||
}
|
||||
return cur
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveMergedOptions(
|
||||
instance: ComponentInternalInstance
|
||||
): ComponentOptions {
|
||||
|
||||
Reference in New Issue
Block a user