@cc-component/cc-ex-component 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/core/ViewModel.ts +12 -9
- package/package.json +1 -1
package/assets/core/ViewModel.ts
CHANGED
|
@@ -112,9 +112,8 @@ export function BindViewModel<T extends new () => any>(constructor: T) {
|
|
|
112
112
|
updateStatus(data, com, value_data, this);
|
|
113
113
|
}
|
|
114
114
|
// 创建实例并转为响应式
|
|
115
|
-
const vm_data = 'viewModel'
|
|
116
115
|
const instance = new constructor();
|
|
117
|
-
this[
|
|
116
|
+
this[baseData] = this._makeReactive(instance, baseData);
|
|
118
117
|
this.onLoadFinish();
|
|
119
118
|
onLoad.call(this);
|
|
120
119
|
|
|
@@ -281,17 +280,12 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
281
280
|
this._bindings = [];
|
|
282
281
|
// 2. 替换 data 为普通对象(破坏 Proxy 响应式)
|
|
283
282
|
this.viewModel = null
|
|
284
|
-
|
|
283
|
+
this.managerData()
|
|
285
284
|
}
|
|
286
285
|
|
|
287
286
|
protected onLoad(): void {
|
|
288
287
|
super.onLoad()
|
|
289
|
-
|
|
290
|
-
const module = this.config.module;
|
|
291
|
-
const name = this.config.name.replace('Window', '');
|
|
292
|
-
const manager: any = (js.getClassByName(`${module}Manager`))
|
|
293
|
-
manager.Ins[`${name}Data`] = this.viewModel
|
|
294
|
-
}
|
|
288
|
+
this.managerData()
|
|
295
289
|
}
|
|
296
290
|
// 在 withDataBinding 返回的 class 中
|
|
297
291
|
protected onDestroy(): void {
|
|
@@ -300,6 +294,15 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
300
294
|
}
|
|
301
295
|
|
|
302
296
|
|
|
297
|
+
managerData() {
|
|
298
|
+
if (this.config) {
|
|
299
|
+
const module = this.config.module;
|
|
300
|
+
const name = this.config.name.replace('Window', '');
|
|
301
|
+
const manager: any = (js.getClassByName(`${module}Manager`))
|
|
302
|
+
manager.Ins[`${name}Data`] = this.viewModel
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
303
306
|
|
|
304
307
|
protected onEnable(): void {
|
|
305
308
|
this.onTouch()
|