Skip to content

Commit 3a16383

Browse files
authored
chore(pagination): 修复eslint问题 (#390)
1 parent 442c34c commit 3a16383

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

packages/devui-vue/devui/pagination/src/components/jump-page.tsx

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const jumpPageProps = {
1010
showJumpButton: Boolean,
1111
totalPages: Number,
1212
cursor: Number,
13-
onChangeCursorEmit: Function as PropType<(v: number) => void>
14-
}
13+
onChangeCursorEmit: Function as PropType<(v: number) => void>,
14+
};
1515

16-
type JumpPageProps = ExtractPropTypes<typeof jumpPageProps>
16+
type JumpPageProps = ExtractPropTypes<typeof jumpPageProps>;
1717

1818
export default defineComponent({
1919
props: jumpPageProps,
@@ -23,41 +23,41 @@ export default defineComponent({
2323
pageIndex,
2424
totalPages,
2525
cursor
26-
} = toRefs(props)
26+
} = toRefs(props);
2727

2828
// 输入跳转页码
29-
const inputNum = ref(pageIndex.value)
29+
const inputNum = ref(pageIndex?.value);
3030
watch(
31-
() => pageIndex.value,
32-
(val: number) => {
33-
inputNum.value = val
31+
() => pageIndex?.value,
32+
(val) => {
33+
inputNum.value = val;
3434
}
35-
)
36-
let curPage = pageIndex.value
35+
);
36+
let curPage = pageIndex?.value;
3737
const jumpPageChange = (currentPage: number) => {
38-
curPage = +currentPage
39-
inputNum.value = currentPage
38+
curPage = +currentPage;
39+
inputNum.value = currentPage;
4040
if (isNaN(currentPage)) {
4141
setTimeout(() => {
42-
inputNum.value = pageIndex.value
43-
}, 300)
42+
inputNum.value = pageIndex?.value;
43+
}, 300);
4444
}
45-
}
45+
};
4646
// 跳转指定页码
4747
const jump = (e: KeyboardEvent | 'btn') => {
48-
if (curPage > totalPages.value) {
49-
return
48+
if (curPage > totalPages?.value) {
49+
return;
5050
}
51-
if ((e === 'btn' || e.key === 'Enter') && cursor.value !== curPage) {
52-
emit('changeCursorEmit', curPage)
51+
if ((e === 'btn' || e.key === 'Enter') && cursor?.value !== curPage) {
52+
emit('changeCursorEmit', curPage);
5353
}
54-
}
54+
};
5555

5656
return {
5757
inputNum,
5858
jumpPageChange,
5959
jump
60-
}
60+
};
6161
},
6262
render() {
6363
const {
@@ -67,20 +67,18 @@ export default defineComponent({
6767
jumpPageChange,
6868
jump,
6969
showJumpButton
70-
} = this
71-
70+
} = this;
71+
const inputProps = {
72+
class: ['devui-pagination-input', size ? 'devui-pagination-input-' + size : ''],
73+
size: size,
74+
modelValue: String(inputNum),
75+
"onUpdate:modelValue": jumpPageChange,
76+
onKeydown: jump,
77+
};
7278
return (
7379
<div class="devui-jump-container">
7480
{goToText}
75-
76-
<d-input
77-
class={['devui-pagination-input', size ? 'devui-pagination-input-' + size : '']}
78-
size={size}
79-
modelValue={String(inputNum)}
80-
onUpdate:modelValue={jumpPageChange}
81-
onKeydown={jump}
82-
/>
83-
81+
<d-input {...inputProps} />
8482
{
8583
// TODO 加入国际化后,替换为当前语言为中文的时候加上 '页'
8684
goToText === '跳至' && '页'
@@ -96,6 +94,6 @@ export default defineComponent({
9694
</div>
9795
}
9896
</div>
99-
)
97+
);
10098
}
101-
})
99+
});

0 commit comments

Comments
 (0)