在vue中使用screenfull.js实现网页全屏:
1、npm 下载到项目中:npm install --save screenfull
2、在需要用到的组件中引入:import screenfull from 'screenfull'
3、定义全屏点击方法:
1
data(){
return{
isFullscreen: false, //默认不全屏
}
}
/** 2 * 全屏 3 */ 4 clickFullscreen() { 5 if (!screenfull.isEnabled) { 6 this.$message({ 7 message: "you browser can not work", 8 type: "warning" 9 }); 10 return false; 11 } 12 screenfull.toggle(); 13 },
参考:https://blog.csdn.net/qq_39009348/article/details/81144121