Vuejs Error: The client-side rendered virtual DOM tree is not matching server-rendered

前端 未结 12 1267
广开言路
广开言路 2020-12-05 02:50

I am using Nuxt.js / Vuejs for mmy app, and I keep facing this error in different places:

    The client-side rendered virtual DOM tree is not matching serve         


        
相关标签:
12条回答
  • 2020-12-05 03:26

    What about:

    extend (config, ctx) {
      config.resolve.symlinks = false
    }
    

    See this [Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content ( Nuxt / Vue / lerna monorepo )

    0 讨论(0)
  • 2020-12-05 03:28

    For Nuxt version above 2.10 it doesn't need to install nothing, just use the default component <client-only> as mentioned https://nuxtjs.org/api/components-client-only/.

    0 讨论(0)
  • 2020-12-05 03:28

    This error can be really painfull to debug. In order to quickly get the element causing an issue edit node_modules/vue/dist/vue.esm.js and add the following lines :

    // Search for this line: 
    function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
        var i;
        var tag = vnode.tag;
        var data = vnode.data;
        var children = vnode.children;
        inVPre = inVPre || (data && data.pre);
        vnode.elm = elm;
    
        // Add the following lines: 
        console.log('elm', elm)
        console.log('vnode', vnode)
        console.log('inVpre', inVPre)
        // ...
    
    
    

    You will get in the console the failing node.

    0 讨论(0)
  • 2020-12-05 03:29

    Turns out, in my case, I had HTML comment tags , which was causing this stupid, annoying error. Took me too long to figure it out but in case it helps someone.

    0 讨论(0)
  • 2020-12-05 03:32

    Ok this is going to sound silly. I tried a bunch of different solutions for about 15 mins such as restarting the server and deleting the .nuxt directory but I was too lazy to use @budden73's big brain solution. What ended up working for me was simply restarting my computer, give it a shot.

    0 讨论(0)
  • 2020-12-05 03:34

    For me this error happened cuz get Array list in AsyncData and rendered <tr> tags by v-for, i put v-for codes in <client-only> blocks and problem solved

    0 讨论(0)
提交回复
热议问题