hilongjw / vue-lazyload

A Vue.js plugin for lazyload your Image or Component in your application.
http://hilongjw.github.io/vue-lazyload/
MIT License
8.01k stars 868 forks source link

LazyComponent used with SSR results in: [Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. #284

Open Coletrane opened 6 years ago

Coletrane commented 6 years ago

Hi I'm using vue-lazyload with Nuxt and trying to get lazy-component to work with SSR.

Here is a repo with an example of the issue: https://github.com/Coletrane/vue-lazyload-ssr-lazy-component clone it and run npm run dev

Here is the example component from that repo:

<template>
  <div>
    <div :style="{
      height: '5000px',
      background: 'black'
    }">
    </div>
    <lazy-component @show="handler">
      <div>
        hello I'm really lazy
      </div>
    </lazy-component>
  </div>
</template>
<script>
export default {
  name: "index",
  methods: {
    handler() {
      console.log("lazy being lazy!")
    }
  }
}
</script>
<style scoped>
</style>
elpeyotl commented 6 years ago

Did you use ssr:false? my nuxt config:

plugins: ['~/plugins/helpers',{ src: '~/plugins/lazyload', ssr: false }]

Coletrane commented 6 years ago

@elpeyotl yes https://github.com/Coletrane/vue-lazyload-ssr-lazy-component/blob/master/nuxt.config.js

kvanska commented 6 years ago

@Coletrane did you find a solution for this? I have same problem using nuxt ssr.

snsxn commented 6 years ago

I'm using it inside no-ssr to avoid this