Home >Web Front-end >JS Tutorial >Detailed explanation of using style binding in React
This time I will bring you a detailed explanation of the use of style binding in React. What are the precautions when using style binding in React. The following is a practical case, let's take a look.
app.css
.c1{ color: red; width: 100%; height: 300px; border: solid 1px red; }
app.js
import './app.css' import React from 'react'; import ReactDOM from 'react-dom'; import './modules/cp/cp.scss' class Component1 extends React.Component{ render(){ return ( <p className="c1"></p> ) } } ReactDOM.render( <Component1 />, document.getElementById('app') )
let c1 = { color: 'red', width: '100%', height: '300px', border: 'solid 1px red' } class Component1 extends React.Component{ render(){ console.log(c1) return ( <p style={c1}></p> ) } }
Believe it or not After reading the case in this article, you have mastered the method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
Detailed explanation of the steps to select li highlighting in react
EasyCanvas drawing library is used in Pixeler project development Practical summary
The above is the detailed content of Detailed explanation of using style binding in React. For more information, please follow other related articles on the PHP Chinese website!