b3ac7fe6a26064464c95fc5e8cbb096f7700e197.svn-base 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div>
  3. <svg-icon :icon-class="isFullscreen?'exit-fullscreen':'fullscreen'" @click="click" />
  4. </div>
  5. </template>
  6. <script>
  7. import screenfull from 'screenfull'
  8. export default {
  9. name: 'Screenfull',
  10. data() {
  11. return {
  12. isFullscreen: false
  13. }
  14. },
  15. mounted() {
  16. this.init()
  17. },
  18. beforeDestroy() {
  19. this.destroy()
  20. },
  21. methods: {
  22. click() {
  23. if (!screenfull.enabled) {
  24. this.$message({
  25. message: 'you browser can not work',
  26. type: 'warning'
  27. })
  28. return false
  29. }
  30. screenfull.toggle()
  31. },
  32. change() {
  33. this.isFullscreen = screenfull.isFullscreen
  34. },
  35. init() {
  36. if (screenfull.enabled) {
  37. screenfull.on('change', this.change)
  38. }
  39. },
  40. destroy() {
  41. if (screenfull.enabled) {
  42. screenfull.off('change', this.change)
  43. }
  44. }
  45. }
  46. }
  47. </script>
  48. <style scoped>
  49. .screenfull-svg {
  50. display: inline-block;
  51. cursor: pointer;
  52. fill: #5a5e66;;
  53. width: 20px;
  54. height: 20px;
  55. vertical-align: 10px;
  56. }
  57. </style>