mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
docs(@vant/use): add usePageVisibility doc
This commit is contained in:
parent
c24d0aaa00
commit
d5104ec81c
@ -57,15 +57,15 @@ export default {
|
|||||||
## 类型定义
|
## 类型定义
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type Options = {
|
|
||||||
eventName?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
function useClickAway(
|
function useClickAway(
|
||||||
target: Element | Ref<Element>,
|
target: Element | Ref<Element>,
|
||||||
listener: EventListener,
|
listener: EventListener,
|
||||||
options?: Options
|
options?: Options
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
|
type Options = {
|
||||||
|
eventName?: string;
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
## 参数
|
## 参数
|
||||||
|
@ -33,17 +33,17 @@ export default {
|
|||||||
## 类型定义
|
## 类型定义
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type Options = {
|
|
||||||
target?: EventTarget | Ref<EventTarget>;
|
|
||||||
capture?: boolean;
|
|
||||||
passive?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
function useEventListener(
|
function useEventListener(
|
||||||
type: string,
|
type: string,
|
||||||
listener: EventListener,
|
listener: EventListener,
|
||||||
options?: Options
|
options?: Options
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
|
type Options = {
|
||||||
|
target?: EventTarget | Ref<EventTarget>;
|
||||||
|
capture?: boolean;
|
||||||
|
passive?: boolean;
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
## 参数
|
## 参数
|
||||||
|
36
packages/vant-use/src/usePageVisibility/README.zh-CN.md
Normal file
36
packages/vant-use/src/usePageVisibility/README.zh-CN.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# usePageVisibility
|
||||||
|
|
||||||
|
获取页面的可见状态。
|
||||||
|
|
||||||
|
## 代码演示
|
||||||
|
|
||||||
|
### 基本用法
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { watch } from 'vue';
|
||||||
|
import { usePageVisibility } from '@vant/use';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const pageVisibility = usePageVisibility();
|
||||||
|
|
||||||
|
watch(pageVisibility, (value) => {
|
||||||
|
console.log('visibility: ', value);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## 类型定义
|
||||||
|
|
||||||
|
```ts
|
||||||
|
function usePageVisibility(): Ref<VisibilityState>;
|
||||||
|
|
||||||
|
type VisibilityState = 'visible' | 'hidden';
|
||||||
|
```
|
||||||
|
|
||||||
|
## 返回值
|
||||||
|
|
||||||
|
| 参数 | 说明 | 类型 | 默认值 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| visibilityState | 页面当前的可见状态,`visible` 为可见,`hidden` 为隐藏 | _Ref<VisibilityState>_ | - |
|
Loading…
x
Reference in New Issue
Block a user