用createGlobalStyle定义全局样式
1.style.js
import {createGlobalStyle } from 'styled-components'
export const Globalstyle = createGlobalStyle`
body {
margin: 0;
padding: 0;
color:red;
}
`
2.在项目主文件导入样式,按组件方式使用
import React , {Component} from 'react';
import {Globalstyle} from './style.js';
class App extends Component {
render() {
return (
<div >
<Globalstyle/>
hello world
</div>
);
}
}
export default App;