因为用了VUE做的官网,既然是官网了避免不了SEO的问题了(该死当初就不应该选择用vue)

很自然就是选择了使用nuxt.js来做ssr预渲染了。

因为网站不是响应式的,PC / 移动端要进行对应跳转,故使用了 window.οnresize 监听窗口变化

然鹅。。。。。

nuxt遇到的问题(一)window 或 document is not defined

 

window is not defined

    ***  碰到这种报错,是由于nuxt.js会在服务端渲染页面,而服务端并没有window或document  ***   

 

  • 官方给出的解决方案如下:

nuxt遇到的问题(一)window 或 document is not defined

so....

1 if (process.client) {
2   window.onresize(function(){
3     //code
4   })
5 }

问题解决了,随带附上 官方传送门

 

相关文章:

  • 2021-07-12
  • 2022-12-23
  • 2021-10-07
  • 2021-04-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2021-07-08
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案