<template>
<div class="hello">
<div ref="fullScreen" style="background: white">
<p>是否全屏: {{isFullscreen}}</p>
<button @click="setFull" id="a">全屏</button>
<button @click="exitFull">退出全屏</button>
<button @click="toggle">toggle切换</button>
</div>
</div>
</template>
<script lang="ts">
import { useFullscreen } from "v3hooks";
export default {
setup() {
const [ isFullscreen, { setFull, exitFull, toggle } ] = useFullscreen();
// useVirtualList测试
return {
isFullscreen,
setFull,
exitFull,
toggle
};
}
};
</script>
<template>
<div class="hello">
<div ref="fullScreen" style="background: white">
<p>是否全屏: {{isFullscreen}}</p>
<button @click="setFull" id="a">全屏</button>
<button @click="exitFull">退出全屏</button>
<button @click="toggle">toggle切换</button>
</div>
</div>
</template>
<script lang="ts">
import { ref } from 'vue';
import { useFullscreen } from "v3hooks";
export default {
setup() {
const fullScreen = ref();
const [ isFullscreen, { setFull, exitFull, toggle } ] = useFullscreen(fullScreen, {
onFull: ()=>{
console.log('全屏')
},
onExitFull: ()=>{
console.log('非全屏')
}
});
return {
isFullscreen,
setFull,
exitFull,
toggle,
fullScreen
};
}
};
</script>
useFullscreen接受一个HTMLElement, 导出操作方法.
interface Actions {
setFull: () => void;
exitFull: () => void;
toggle: () => void;
}
const useFullscreen: (
target?: Target$1 | undefined,
options?: Options | undefined
) => [
isFullscreen: Ref<boolean>,
actions: Actions
];