-
You can make the React className use arrays directly
-
download
npm install class-array-loader -D
Copy the code
- webpack.config.js
{
test: /\.(js|tsx|jsx|ts)$/.loader: require.resolve('class-array-loader')}Copy the code
- use
<div className={['class1','class2']}>demo</div>
Copy the code
-
Style can be used in RPX units in JSX code, which automatically converts rem
-
download
npm install jsx-to-rem-loader -D
Copy the code
- webpack.config.js
{
test: /\.(js|tsx|jsx|ts)$/.loader: require.resolve('jsx-to-rem-loader'),
options: {
remUnit: 37.5.// Calculate the number of decimal places
remFixed: 8}},Copy the code
- use
<div style={{ width: "30RPX" }}>demo</div>
Copy the code
- You can click on a little star if you like
- class-array-loader
- jsx-to-rem-loader
- Leave a message if you have any questions