diff --git a/package.json b/package.json index 2a0a265..efc6e74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wkit", - "version": "1.10.5", + "version": "1.10.6", "type": "module", "description": "A library for building fast, lightweight web components.", "main": "dist/index.js", diff --git a/src/index.js b/src/index.js index 685417b..fda8e55 100644 --- a/src/index.js +++ b/src/index.js @@ -201,12 +201,20 @@ export class Component extends HTMLElement { #createProxy(name, options, newValue) { return new Proxy(newValue || options.default, { - set: (target, prop, value) => { + get: (target, prop, receiver) => { + let value = Reflect.get(target, prop, receiver) + // 当访问的值是对象时,需要对这个对象也进行代理 + if (typeof value === 'object') { + return this.#createProxy(value) + } + return value + }, + set: (target, prop, value, receiver) => { if (prop === 'length' && options.type === Array) { return true } let oldValue = target[prop] - target[prop] = value + Reflect.set(target, key, value, receiver) this.$requestUpdate(name) if (options.observer) {