injectGlobal 方法替换成了 createGlobalStyle 没有任何的报错初始化样式不生效
来源:7-1 项目目录搭建,Styled-Components 与 Reset.css 的结合使用
上官元西
2019-03-12
app.js文件
import React, { Component } from "react";
import { GlobalStyle } from "./style";
class App extends Component {
render() {
return (
<div>
<GlobalStyle />
<div className="dell">你好</div>
</div>
);
}
}
export default App;
style.js文件
import { createGlobalStyle } from "styled-components";
export const GlobalStyle = createGlobalStyle`
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td { margin:0; padding:0; }
body, button, input, select, textarea { font:12px/1.5tahoma, arial, \5b8b\4f53; }
h1, h2, h3, h4, h5, h6{ font-size:100%; }
address, cite, dfn, em, var { font-style:normal; }
code, kbd, pre, samp { font-family:couriernew, courier, monospace; }
small{ font-size:12px; }
ul, ol { list-style:none; }
a { text-decoration:none; }
a:hover { text-decoration:underline; }
sup { vertical-align:text-top; }
sub{ vertical-align:text-bottom; }
legend { color:#000; }
fieldset, img { border:0; }
button, input, select, textarea { font-size:100%; }
`;
写回答
3回答
-
把你样式里的第二行 字体样式后面的 \5b8b\4f53 删掉
20 -
月美
2019-03-24
你好请问解决了吗,我也是全局样式不生效
022019-03-24 -
Dell
2019-03-12
我看下报错内容
00