fix: Page 组件不能设置 page 参数

This commit is contained in:
unanmed 2025-06-25 12:13:13 +08:00
parent e0b3b2a68b
commit ef0c6a1647

View File

@ -8,7 +8,7 @@ import {
VNode,
watch
} from 'vue';
import { clamp } from 'lodash-es';
import { clamp, isNil } from 'lodash-es';
import { DefaultProps, ElementLocator, Font } from '@motajs/render';
import { SetupComponentOptions } from '@motajs/system-ui';
@ -177,6 +177,18 @@ export const Page = defineComponent<
updateRectAndText();
}
);
watch(
() => props.page,
page => {
if (!isNil(page)) {
const target = clamp(page, 0, props.pages - 1);
if (nowPage.value !== target) {
nowPage.value = target;
emit('pageChange', target);
}
}
}
);
/**
*