Home  >  Article  >  Web Front-end  >  What to do if react component style reference fails

What to do if react component style reference fails

藏色散人
藏色散人Original
2023-01-04 10:52:462352browse

React component style reference failure solution: 1. Download and install the antd dependency package through "npm i --save antd"; 2. Introduce the antd style at the top of index.css; 3. Through "import { Button } from "antd";" Just introduce the desired components into the project.

What to do if react component style reference fails

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

What should I do if the style reference of react component fails?

About the problem that the antd style introduced in the react project does not take effect

1. Download and install the antd dependency package in the react project

npm i --save antd

2. In index. Introduce antd style at the top of css (antd document says to introduce style at the top of app.css, I don’t know why the style doesn’t take effect when I tried it)

@import '~antd/dist/antd.css';

3. Introduce it into the project The components we want, so we can see the effect!

import { Button } from "antd";

6d1111a865a2d4d2a411253e652972f2This is a button51738bfe3c0543748d57de456193ed4a

Recommended learning: "react video tutorial

The above is the detailed content of What to do if react component style reference fails. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn