iter(g285): 分页总量支持信号并钳回越界页码

This commit is contained in:
HIsheR
2026-10-26 23:14:28 +08:00
parent 56ad087e56
commit d1b213fb01
6 changed files with 38 additions and 12 deletions
+13
View File
@@ -1363,6 +1363,19 @@ const content = h(
pagination({ page: simplePage, pageSize: 20, total: 9, hideOnSinglePage: true }), // 单页:整块不渲染
h('span', { class: 'out' }, '单页隐藏:上面那块 9 条 / 每页 20 已自动消失'),
),
(() => {
// 总量走信号:点「筛到 25 条」后页码从 14 自动钳到 3,父级 state 同步收到回调
const liveTotal = signal(137);
const livePage = signal(14);
return h(
'div',
{ class: 'row' },
pagination({ page: livePage, pageSize: 10, total: liveTotal, onChange: (p) => livePage(p) }),
button({ label: '总量 137 条', variant: 'ghost', onClick: () => liveTotal(137) }),
button({ label: '筛到 25 条', variant: 'ghost', onClick: () => liveTotal(25) }),
h('span', { class: 'out' }, () => `第 ${livePage()} 页 / 共 ${Math.max(1, Math.ceil(liveTotal() / 10))} 页`),
);
})(),
),
section(
'sec-menu',