We can implement the full-screen function directly by handwriting, but it is very convenient to use the screenfull plug-in to deal with the full-screen problem, but today I encountered a bug in normal use
- Install npm packages
npm i screenfull
default to the latest version - import
import ScreenFull from 'screenfull'
using - Use the full screen function normally
ScreenFull.toggle()
At this time, an error was reported to me.
The page was blank and could not be loaded. I went to the Internet to find several articles and said that the version was too high, and the version of the package plugin needs to be reduced. I tried many times and still reported an error.
- solve
It is true that the version needs to be lowered. I have to downgrade to the [email protected] version, so why is an error reported? I found that the path we imported is screenfull in the module directory, but there is no corresponding index.js file in it at all,
so we have to change the imported pathimport ScreenFull from 'screenfull/dist/screenfull'
, the page will be displayed normally, and the full-screen function will be normal.