I. Emergence of Problems:
- , in the previous project development, the error occurred when applying
male-components
, applying injectGlobal
to define style variables, and injectGlobal 'is not exported from' application-components '
. Ii. Analysis and Solution of problems:
The reason for
- problem is that
The injectGlobal API was removed and removed by createGlobalStyle in styled-components v4.
API is removed and replaced by malt-components v4. Replaced with createGlobalStyle
the new API
appears as a style component and is introduced as a label based on the style component idea. InjectGlobal cannot be applied directly as the original injectGlobal
. We define a global style variable that will be inserted into the document as a component. Solution: The first step is to define the global style with createGlobalStyle
and wrap the global style in it. Wrap the CSS
style with the back-quotation string, as shown below:
import { createGlobalStyle } from 'styled-components'
export const Globalstyle = createGlobalStyle`
body{
margin: 0;
padding: 0
}`
The second step is to import the style in the project main file. The code is as follows:
import { Globalstyle } from './style'
The third step is introduced as a label in the form of a style component, as shown below:
class App extends Component {
render () {
return (
<Fragment>
<GlobalStyled/>
</Fragment>
)
}
}
Read More:
- Solution of “do not use ‘new’ for side effects” for eslint verification of Vue project
- Vue element admin configure global styles
- Research on invalid modification of elementui component style
- Invalidation of margin top property of nested box in CSS style box
- [Altium problem] “extra pin u1-22 in normal of part U1”
- Tensorflow tf.train.exponential_ Decay function (exponential decay method)
- Uncaught Error: Script error for ” popper.js “, needed by: bootstrap solution
- Error: global variable is ambiguous (conflict between using namespace STD and global variable)
- After eclipse eclipse eclipse imports the correct project, an error is reported in XML and other files
- ISDEV : fatal error -6109: Internal build error
- Solving ora-21561: oid generation failed
- Springboot + mybatis + logback does not print SQL problems on the console
- Error inflating class fragment error when loading custom fragment with fragment (valid)
- Idea running error running ‘application’: solution to command line is too long
- How can IntelliJ idea completely delete a project
- React bootstrap loading and how to use modules
- VUEJS Failed to execute ‘removeChild’ on ‘Node’: The node to be removed is not a child of
- Python — using Matplotlib to draw histogram
- In echarts label.formatter Non effectiveness