Using the screenfull plugin to report an error

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 screenfulldefault to the latest version
  • import import ScreenFull from 'screenfull'using
  • Use the full screen function normallyScreenFull.toggle()

At this time, an error was reported to me.
insert image description here
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,
insert image description here
so we have to change the imported path import ScreenFull from 'screenfull/dist/screenfull', the page will be displayed normally, and the full-screen function will be normal.

Guess you like

Origin blog.csdn.net/weixin_47979372/article/details/124071471