Static GitHub Issues

[3096] How do I add a listener event on the server side?

prev: How to use dynamic NON-async components for nuxt generate
next: too much dependencies in nuxt.js

I need to add a listening keyboard event to the page, but now I'm using nuxt to add the listener failure.

` created(){ //注册全局变量

  if(process.browser){
    const _this = this;
    _this.hotelMarquee = this.hotel[this.language_code].length>18;
    document.onkeydown = function(e) {
      _this.changeLanguage(e.which)
    };
  }
},

} ` The results of the operation are wrongly reported as follows:

[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2680">#c2680</a>)</em></sub></div>