SSR context.renderStyles() returns empty string
See original GitHub issueVersion
2.4.1
Reproduction link
http://plnkr.co/edit/Gtp3uFFiBIxYMmyh3Se9
Steps to reproduce
webpack config rules : {test: /.css$/, loader: “vue-style-loader!css-loader”}
<script>
import './common.css';
export default {
name: 'app',
};
</script>
<template src="./app.html"></template>
context has _styles property but context.renderStyles() returns empty string why is it? client side works fine. I don’t know what I missed. please help.
有context._styles,不过context.renderStyles()的结果是“” 为什么?
浏览器上是正常添加STYLE。
不知道错过了什么,求解
What is expected?
context.renderStyles() => “<style>body {…}</style>”
What is actually happening?
context.renderStyles() => “”
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Server Side Rendering - renderToString returns empty html
I'm trying to render react application on server, but it seems that renderToString function doesn't render markup properly, ...
Read more >@minstack/styled - npm
If a CSS property value is "empty" (empty string, false , null , undefined ... The SSR manager's getStyleTags() method returns a single...
Read more >Server-Side Rendering (SSR) - Vue.js
renderToString() takes a Vue app instance and returns a Promise that resolves to the rendered HTML of the app. It is also possible...
Read more >Demystifying server-side rendering in React - freeCodeCamp
Server-Side Rendering — SSR from here on — is the ability of a ... The initial server request is generally returning an empty...
Read more >Server Side Rendering - Search.io React SDK
This signals to all nested components that they are being rendered in an SSR context. If you're using @sajari/react-search-ui ... Copy.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, so I looked at your setup and it’s because in here you are using
extends: app
so essentially yourapp
component is also the root component. The SSR CSS is injected in each component’sbeforeCreate
hook, however you created the root instance before the render starts, so the injected CSS never got registered.What you need to do is make the root component a wrapper:
@yyx990803 Thank you very very much ❤️ work like a charm You’re the king god maestro emperor code meister! Vue.js forever xD