feat(reactivity): return array when calling toRefs on array (#1768)
close #1764
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { track, trigger } from './effect'
|
||||
import { TrackOpTypes, TriggerOpTypes } from './operations'
|
||||
import { isObject, hasChanged } from '@vue/shared'
|
||||
import { isArray, isObject, hasChanged } from '@vue/shared'
|
||||
import { reactive, isProxy, toRaw, isReactive } from './reactive'
|
||||
import { CollectionTypes } from './collectionHandlers'
|
||||
|
||||
@@ -121,7 +121,7 @@ export function toRefs<T extends object>(object: T): ToRefs<T> {
|
||||
if (__DEV__ && !isProxy(object)) {
|
||||
console.warn(`toRefs() expects a reactive object but received a plain one.`)
|
||||
}
|
||||
const ret: any = {}
|
||||
const ret: any = isArray(object) ? new Array(object.length) : {}
|
||||
for (const key in object) {
|
||||
ret[key] = toRef(object, key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user