mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(@vant/use): fix some lint issues (#8462)
This commit is contained in:
parent
fe453dabb1
commit
ace4c9b60b
@ -59,15 +59,15 @@ export default {
|
|||||||
### 类型定义
|
### 类型定义
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
type Options = {
|
||||||
|
eventName?: string;
|
||||||
|
};
|
||||||
|
|
||||||
function useClickAway(
|
function useClickAway(
|
||||||
target: Element | Ref<Element | undefined>,
|
target: Element | Ref<Element | undefined>,
|
||||||
listener: EventListener,
|
listener: EventListener,
|
||||||
options?: Options
|
options?: Options
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
type Options = {
|
|
||||||
eventName?: string;
|
|
||||||
};
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 参数
|
### 参数
|
||||||
|
@ -62,13 +62,13 @@ export default {
|
|||||||
### 类型定义
|
### 类型定义
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
function useCountDown(options: UseCountDownOptions): CountDown;
|
type CurrentTime = {
|
||||||
|
days: number;
|
||||||
type UseCountDownOptions = {
|
hours: number;
|
||||||
time: number;
|
total: number;
|
||||||
millisecond?: boolean;
|
minutes: number;
|
||||||
onChange?: (current: CurrentTime) => void;
|
seconds: number;
|
||||||
onFinish?: () => void;
|
milliseconds: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CountDown = {
|
type CountDown = {
|
||||||
@ -78,14 +78,14 @@ type CountDown = {
|
|||||||
current: ComputedRef<CurrentTime>;
|
current: ComputedRef<CurrentTime>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CurrentTime = {
|
type UseCountDownOptions = {
|
||||||
days: number;
|
time: number;
|
||||||
hours: number;
|
millisecond?: boolean;
|
||||||
total: number;
|
onChange?: (current: CurrentTime) => void;
|
||||||
minutes: number;
|
onFinish?: () => void;
|
||||||
seconds: number;
|
|
||||||
milliseconds: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function useCountDown(options: UseCountDownOptions): CountDown;
|
||||||
```
|
```
|
||||||
|
|
||||||
### 参数
|
### 参数
|
||||||
|
@ -33,17 +33,17 @@ export default {
|
|||||||
## 类型定义
|
## 类型定义
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
function useEventListener(
|
|
||||||
type: string,
|
|
||||||
listener: EventListener,
|
|
||||||
options?: Options
|
|
||||||
): void;
|
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
target?: EventTarget | Ref<EventTarget>;
|
target?: EventTarget | Ref<EventTarget>;
|
||||||
capture?: boolean;
|
capture?: boolean;
|
||||||
passive?: boolean;
|
passive?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function useEventListener(
|
||||||
|
type: string,
|
||||||
|
listener: EventListener,
|
||||||
|
options?: Options
|
||||||
|
): void;
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
@ -26,9 +26,9 @@ export default {
|
|||||||
### 类型定义
|
### 类型定义
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
function usePageVisibility(): Ref<VisibilityState>;
|
|
||||||
|
|
||||||
type VisibilityState = 'visible' | 'hidden';
|
type VisibilityState = 'visible' | 'hidden';
|
||||||
|
|
||||||
|
function usePageVisibility(): Ref<VisibilityState>;
|
||||||
```
|
```
|
||||||
|
|
||||||
### 返回值
|
### 返回值
|
||||||
|
@ -31,7 +31,9 @@ export default {
|
|||||||
### 类型定义
|
### 类型定义
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
function useRect((Element | Window) | Ref<Element | Window | undefined>): DOMRect;
|
function useRect(
|
||||||
|
element: Element | Window | Ref<Element | Window | undefined>
|
||||||
|
): DOMRect;
|
||||||
```
|
```
|
||||||
|
|
||||||
### 返回值
|
### 返回值
|
||||||
|
@ -16,9 +16,9 @@ function makeDOMRect(width: number, height: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useRect = (
|
export const useRect = (
|
||||||
elementRef: (Element | Window) | Ref<Element | Window | undefined>
|
elementOrRef: Element | Window | Ref<Element | Window | undefined>
|
||||||
) => {
|
) => {
|
||||||
const element = unref(elementRef);
|
const element = unref(elementOrRef);
|
||||||
|
|
||||||
if (isWindow(element)) {
|
if (isWindow(element)) {
|
||||||
const width = element.innerWidth;
|
const width = element.innerWidth;
|
||||||
|
@ -23,10 +23,7 @@ export function useParent<T>(key: string | symbol) {
|
|||||||
const { link, unlink, internalChildren, ...rest } = parent;
|
const { link, unlink, internalChildren, ...rest } = parent;
|
||||||
|
|
||||||
link(instance);
|
link(instance);
|
||||||
|
onUnmounted(() => unlink(instance));
|
||||||
onUnmounted(() => {
|
|
||||||
unlink(instance);
|
|
||||||
});
|
|
||||||
|
|
||||||
const index = computed(() => internalChildren.indexOf(instance));
|
const index = computed(() => internalChildren.indexOf(instance));
|
||||||
|
|
||||||
|
@ -24,7 +24,5 @@ export function cancelRaf(id: number) {
|
|||||||
|
|
||||||
// double raf for animation
|
// double raf for animation
|
||||||
export function doubleRaf(fn: FrameRequestCallback): void {
|
export function doubleRaf(fn: FrameRequestCallback): void {
|
||||||
raf(() => {
|
raf(() => raf(fn));
|
||||||
raf(fn);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user