-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何让自己写的组件支持 SSR? #3660
Comments
SSR运行在node环境,node环境不存在全局变量document,需要使用jsdom |
我的组件里需要用到 document 和 window 的都做了环境判断,并且直接 import 组件源码是 SSR work 的,但是发布到 npm 之后,通过包来 import 就无法 work 了 |
因为 |
@sodatea 是的,已经解决了,谢谢 |
@sodatea 如果这里有 css 样式,但是又不想在 import component 的时候额外 import style 该怎么做呢? |
This was referenced Aug 18, 2021
This was referenced Sep 12, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem does this feature solve?
我使用 vue-cli 3 写了一个组件:vue-flow-render
如果我把 src 下面的两个组件 copy 到一个 SSR 的项目中,它可以 work
但我把这个包发布到 npm 上再引入后,就会报错:
document is not defined
我不知道我该去修改什么地方,可以告诉我吗?
What does the proposed API look like?
需要如何修改 vue.config.js 就能够支持 build 后的包能在 SSR 的时候运行
The text was updated successfully, but these errors were encountered: