@cc-component/cc-ex-component 2.0.4 → 2.0.6
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 +15 -1
- package/package.json +1 -1
package/assets/core/ViewModel.ts
CHANGED
|
@@ -296,6 +296,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
296
296
|
const self = this as any;
|
|
297
297
|
return new Proxy(obj, {
|
|
298
298
|
get(target, key: string) {
|
|
299
|
+
|
|
299
300
|
// ✅ 跳过 $ 开头的属性:直接返回原始值,不代理
|
|
300
301
|
if (key.startsWith(skip)) {
|
|
301
302
|
return target[key];
|
|
@@ -306,6 +307,16 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
306
307
|
// console.log(`get ${pathPrefix}----${key}`);
|
|
307
308
|
// return self._makeReactive(value, `${pathPrefix}.${key}`);
|
|
308
309
|
// }
|
|
310
|
+
|
|
311
|
+
//绑定的方法
|
|
312
|
+
const funcName = bindingMapFunc.get(self.className)?.get(key)
|
|
313
|
+
if (funcName) {
|
|
314
|
+
const result = self[funcName]?.(value); // 调用函数获取返回值
|
|
315
|
+
// ✅ 关键:如果返回值不是 undefined,则返回计算值
|
|
316
|
+
if (result !== undefined) {
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
309
320
|
return value;
|
|
310
321
|
},
|
|
311
322
|
set(target, key: string, value: any) {
|
|
@@ -433,7 +444,10 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
433
444
|
}
|
|
434
445
|
|
|
435
446
|
private refreshFuncName() {
|
|
436
|
-
|
|
447
|
+
// console.error('刷新数据失败:', this.funcMap)
|
|
448
|
+
this.funcMap.forEach((value, key) => {
|
|
449
|
+
this[key]?.(value)
|
|
450
|
+
})
|
|
437
451
|
}
|
|
438
452
|
|
|
439
453
|
resetButtonScale(btn: Button) {
|