获取页面的可见状态。
import { watch } from 'vue';
import { usePageVisibility } from '@vant/use';
export default {
setup() {
const pageVisibility = usePageVisibility();
watch(pageVisibility, (value) => {
console.log('visibility: ', value);
});
},
};
type VisibilityState = 'visible' | 'hidden';
function usePageVisibility(): Ref<VisibilityState>;
参数 | 说明 | 类型 |
---|---|---|
visibilityState | 页面当前的可见状态,visible 为可见,hidden 为隐藏 | Ref<VisibilityState> |