mirror of
https://github.com/motajs/template.git
synced 2026-11-09 03:34:30 +08:00
fix: custom 的 binding 参数
This commit is contained in:
1 parent
e0f3a5b2df
commit
bf6d64cce1
2 files changed
+3
-17
No files matched your search
@@ -84,7 +84,7 @@ export interface CustomProps extends BaseProps {
|
||||
/** 自定义的渲染函数 */
|
||||
render?: CustomRenderFunction;
|
||||
/** 更新绑定,当数组中的任意一项更新时将会自动更新此元素的渲染 */
|
||||
bindings?: Ref<any>[];
|
||||
bindings?: readonly unknown[];
|
||||
}
|
||||
|
||||
export interface ContainerProps extends BaseProps {}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { RenderItem } from './item';
|
||||
import { MotaOffscreenCanvas2D } from './canvas2d';
|
||||
import { CustomRenderFunction } from './types';
|
||||
import { Ref } from 'vue';
|
||||
|
||||
export class CustomRenderItem extends RenderItem {
|
||||
renderFn: CustomRenderFunction;
|
||||
@@ -29,7 +28,7 @@ export class CustomRenderItem extends RenderItem {
|
||||
|
||||
protected handleProps(
|
||||
key: string,
|
||||
prevValue: any,
|
||||
_prevValue: any,
|
||||
nextValue: any
|
||||
): boolean {
|
||||
switch (key) {
|
||||
@@ -39,20 +38,7 @@ export class CustomRenderItem extends RenderItem {
|
||||
return true;
|
||||
case 'bindings':
|
||||
if (!this.assertType(nextValue, Array, key)) return false;
|
||||
if (nextValue !== prevValue) {
|
||||
this.update();
|
||||
} else if (nextValue.length !== prevValue.length) {
|
||||
this.update();
|
||||
} else {
|
||||
const arr: Ref<any>[] = nextValue as Ref<any>[];
|
||||
const prev: Ref<any>[] = prevValue as Ref<any>[];
|
||||
for (let i = 0; i < nextValue.length; i++) {
|
||||
if (arr[i].value !== prev[i].value) {
|
||||
this.update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.update();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user