types(@vant/use): improve Ref param typing

This commit is contained in:
chenjiahan
2020-10-09 20:32:31 +08:00
parent 767ca80499
commit 14d2826cc7
6 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ export default {
```ts
function useClickAway(
target: Element | Ref<Element>,
target: Element | Ref<Element | undefined>,
listener: EventListener,
options?: Options
): void;
+2 -2
View File
@@ -7,7 +7,7 @@ export type UseClickAwayOptions = {
};
export function useClickAway(
target: Element | Ref<Element>,
target: Element | Ref<Element | undefined>,
listener: EventListener,
options: UseClickAwayOptions = {}
) {
@@ -19,7 +19,7 @@ export function useClickAway(
const onClick = (event: Event) => {
const element = unref(target);
if (!element.contains(event.target as Node)) {
if (element && !element.contains(event.target as Node)) {
listener(event);
}
};