template

  1. <span @click="screen">全屏</span>

data

  1. fullscreen:false

methods

  1. screen(){
  2. // let element = document.documentElement;//设置后就是我们平时的整个页面全屏效果
  3. let element = document.getElementById('con_lf_top_div');//设置后就是 id==con_lf_top_div 的容器全屏
  4. if (this.fullscreen) {
  5. if (document.exitFullscreen) {
  6. document.exitFullscreen();
  7. } else if (document.webkitCancelFullScreen) {
  8. document.webkitCancelFullScreen();
  9. } else if (document.mozCancelFullScreen) {
  10. document.mozCancelFullScreen();
  11. } else if (document.msExitFullscreen) {
  12. document.msExitFullscreen();
  13. }
  14. } else {
  15. if (element.requestFullscreen) {
  16. element.requestFullscreen();
  17. } else if (element.webkitRequestFullScreen) {
  18. element.webkitRequestFullScreen();
  19. } else if (element.mozRequestFullScreen) {
  20. element.mozRequestFullScreen();
  21. } else if (element.msRequestFullscreen) {
  22. // IE11
  23. element.msRequestFullscreen();
  24. }
  25. }
  26. this.fullscreen = !this.fullscreen;
  27. }