@cc-component/cc-ex-component 1.6.1 → 1.6.3
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 +8 -4
- package/package.json +1 -1
package/assets/core/ViewModel.ts
CHANGED
|
@@ -93,6 +93,10 @@ export function BindViewModel<T extends new () => any>(constructor: T) {
|
|
|
93
93
|
this.className = className;
|
|
94
94
|
if (!this._bindings) this._bindings = [];
|
|
95
95
|
|
|
96
|
+
// 创建实例并转为响应式
|
|
97
|
+
const instance = new constructor();
|
|
98
|
+
this[baseData] = this._makeReactive(instance, baseData);
|
|
99
|
+
|
|
96
100
|
const map = bindingMap.get(className)
|
|
97
101
|
for (const [propertyKey, value] of map) {
|
|
98
102
|
//属性绑定
|
|
@@ -111,9 +115,7 @@ export function BindViewModel<T extends new () => any>(constructor: T) {
|
|
|
111
115
|
const data = map.get(propertyKey)
|
|
112
116
|
updateStatus(data, com, value_data, this);
|
|
113
117
|
}
|
|
114
|
-
|
|
115
|
-
const instance = new constructor();
|
|
116
|
-
this[baseData] = this._makeReactive(instance, baseData);
|
|
118
|
+
|
|
117
119
|
this.onLoadFinish();
|
|
118
120
|
onLoad.call(this);
|
|
119
121
|
|
|
@@ -478,7 +480,9 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
478
480
|
}
|
|
479
481
|
|
|
480
482
|
function updateStatus(data: IBindingData, com: Component, value: any, self: any) {
|
|
481
|
-
|
|
483
|
+
if (value === undefined || value === null) {
|
|
484
|
+
return
|
|
485
|
+
}
|
|
482
486
|
const sx = data.dataPath.split('.').pop();
|
|
483
487
|
const tempData = { value: value, skip: false }
|
|
484
488
|
//console.log("updateStatus", data.propertyKey)
|