【发布时间】:2022-11-04 17:43:10
【问题描述】:
未显示 tailwind css 类,我通过 tailwindcss.com create-react-app 按照安装过程进行安装。交叉检查,我似乎无法找到为什么它仍然无法正常工作。我确实按照与此问题相关的答案中的说明将反应脚本更新到版本 5.0.1,但它没有解决问题。
这是 package.json 文件
{
"name": "my-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.1.1",
"@testing-library/user-event": "^13.5.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"autoprefixer": "^10.4.7",
"postcss": "^8.4.13",
"tailwindcss": "^3.0.24"
}
}
Tailwind.config.js
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
索引.css
@tailwind base;
@tailwind components;
@tailwind utilities;
function App() {
return <div className="container mx_auto bg-gray-200 rounded-xl">
<p className="text-5xl font-bold">
Welcome
</p>
<p className="text-grey-500 text-lg">
React and Tailwind css updated now
</p>
</div>;
}
export default App;
【问题讨论】:
-
您是否在任何地方导入
index.css? -
在 app.js 中导入 index.css 并且它起作用了。谢谢
标签: reactjs tailwind-css tailwind-3