fix: 优化watch 修改编辑用户弹窗样式
This commit is contained in:
+16
-19
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
// src/hooks/usePagination.ts
|
||||
import { computed, ref, watch, Ref, triggerRef } from 'vue';
|
||||
import { computed, ref, Ref, triggerRef } from 'vue';
|
||||
import { useEffect } from './useEffect';
|
||||
|
||||
/**
|
||||
* 分页配置项
|
||||
@@ -77,24 +78,20 @@ export function usePagination(options: UsePaginationOptions = {}): UsePagination
|
||||
const pageSizeRef = ref(options.pageSize ?? defaultPageSize);
|
||||
const totalRef = ref(options.total ?? 0);
|
||||
|
||||
watch(
|
||||
() => options.current,
|
||||
(val) => {
|
||||
if (val !== undefined) currentRef.value = val;
|
||||
},
|
||||
);
|
||||
watch(
|
||||
() => options.pageSize,
|
||||
(val) => {
|
||||
if (val !== undefined) pageSizeRef.value = val;
|
||||
},
|
||||
);
|
||||
watch(
|
||||
() => options.total,
|
||||
(val) => {
|
||||
if (val !== undefined) totalRef.value = val;
|
||||
},
|
||||
);
|
||||
useEffect(() => {
|
||||
const val = options.current;
|
||||
if (val !== undefined) currentRef.value = val;
|
||||
}, [() => options.current]);
|
||||
|
||||
useEffect(() => {
|
||||
const val = options.pageSize;
|
||||
if (val !== undefined) pageSizeRef.value = val;
|
||||
}, [() => options.pageSize]);
|
||||
|
||||
useEffect(() => {
|
||||
const val = options.total;
|
||||
if (val !== undefined) totalRef.value = val;
|
||||
}, [() => options.total]);
|
||||
|
||||
const totalPages = computed(() => {
|
||||
const total = totalRef.value;
|
||||
|
||||
Reference in New Issue
Block a user