编译错误提示: 'injectGlobal' is not exported from 'styled-components'
原因: styled-components 4.x版本将原来的injectGlobal方法用createGlobalStyle替换了。用法上也有一些不同,如下
import {createGlobalStyle} from 'styled-components';
export const GlobalStyled = createGlobalStyle`
body{
margin:0;
padding:0;
background:red;
}`
import React from 'react';
import {GlobalStyled} from './style.js';
class App extends React.Components{
render(){
return(
<div className='App'>
<GlobalStyled />
</div>
)
}
}