refactor: ♻️ vueVModel优化父子组件数据双向绑定和更新事件代码
Former-commit-id: 44aeaae6f5e8501915108c008d580989fb15df5b
This commit is contained in:
@@ -55,23 +55,11 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:page", "update:limit", "pagination"]);
|
||||
const emit = defineEmits(["pagination"]);
|
||||
|
||||
const currentPage = computed<number | undefined>({
|
||||
get: () => props.page,
|
||||
set: (value) => {
|
||||
emit("update:page", value);
|
||||
},
|
||||
});
|
||||
const currentPage = useVModel(props, "page", emit);
|
||||
|
||||
const pageSize = computed<number | undefined>({
|
||||
get() {
|
||||
return props.limit;
|
||||
},
|
||||
set(val) {
|
||||
emit("update:limit", val);
|
||||
},
|
||||
});
|
||||
const pageSize = useVModel(props, "limit", emit);
|
||||
|
||||
function handleSizeChange(val: number) {
|
||||
emit("pagination", { page: currentPage, limit: val });
|
||||
|
||||
Reference in New Issue
Block a user