安裝npm
npm install --save screenfull
在須要的頁面引用學習
import screenfull from 'screenfull'
全屏使用this
<template> <span @click='clickFullscreen'>全屏</span> </template> <script> import screenfull from 'screenfull' export default{ name: 'screenfull', data(){ return { isFullscreen: false } }, methods:{ clickFullscreen(){ if (!screenfull.isEnabled) { this.$message({ message: 'you browser can not work', type: 'warning' }) return false } screenfull.toggle() } } } </script>
相關學習連接:https://blog.csdn.net/qq_39009348/article/details/81144121spa