Window is not defined??? in nuxt.js How to solve it?

clipboard.png
nuxtapi

clipboard.png

Jun.14,2022

nuxtjs as a server rendering library, the code should be executed in the node environment. The execution environment of the browser is different from that of node. There are no objects such as window or document on node, so an error will be reported.

there are two ways to solve it:

if there is no such object or method, you can populate it with an empty object or method:

  https://juejin.im/post/5cee27...

Menu