xyxiao001 / vue-cropper

A simple picture clipping plugin for vue
https://github.xyxiao.cn/vue-cropper/docs/vue3.html
MIT License
4.3k stars 695 forks source link

希望添加服务器渲染支持 #18

Closed seekcx closed 7 years ago

seekcx commented 7 years ago

RT,我使用nuxt,为这个组件关闭了ssr,但是还是会在浏览器控制台得到一条警告信息。

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

, or missing. Bailing hydration and performing full client-side render.

xyxiao001 commented 7 years ago

是不是因为你的html标签没写结束的, 不完整导致出现这个警告

seekcx commented 7 years ago

我试过

<cropper ref="cropper"></cropper>

<cropper ref="cropper" />

这两种方式都不行,去掉就没有错误了。

xyxiao001 commented 7 years ago

我去研究看看 1j1b wg t6qs4fc1ty up3d

xyxiao001 commented 7 years ago

https://zh.nuxtjs.org/api/configuration-plugins nuxt 使用时貌似需要额外配置 image

seekcx commented 7 years ago

对,

// ./plugins/cropper.js

import Vue from 'Vue'
import VueCropper from 'vue-cropper'

Vue.component('cropper', VueCropper)
// nuxt.config.js

{ src: '~/plugins/cropper', ssr: false},

这些我都做了,应该是服务端没有渲染这个组件,在浏览器端渲染了,vue对比了两边的渲染结果,不一样,给了一个提示?

Hellowor1d commented 6 years ago

@xyxiao001 按照上面的方式进行了设置,还是不行。 报错: ReferenceError: document is not defined

@seekcx 请问你的这个问题后来解决掉了吗?Google 找的多个设置方案都没有生效

seekcx commented 6 years ago

@Hellowor1d 目前还没有解决,

<no-ssr>
     <cropper />
</no-ssr>
{ src: '~/plugins/cropper', ssr: false},

这两种都试了。

WilliamLin1990 commented 6 years ago

@seekcx @Hellowor1d @xyxiao001 现在可以使用nuxt了吗

furyscript commented 6 years ago

@xyxiao001 Can you please update this for nuxt/ssr? The problem come when launch import VueCropper from 'vue-cropper'

Nuxt nothing can do if you use document/window when import. You can use that after plugin init.