话不多说直接上代码
1,先引入onMounted
import { ref, getCurrentInstance,onMounted } from "vue";
2,写一下全屏函数
const allScreen = ()=>{ let domElement = document.documentElement; if (domElement.requestFullscreen) { domElement.requestFullscreen(); } else if (domElement.mozRequestFullScreen) { domElement.mozRequestFullScreen(); } else if (domElement.webkitRequestFullScreen) { domElement.webkitRequestFullScreen(); } }
3,在onMounted里调用次函数
onMounted(()=>{ console.log('进入页面') allScreen() })