Tailwind CSS与React App不起作用 - 无影响
我正在尝试使用React网站使用 NPX Create-React-app myApp
CD我的应用程序
后来,我按照如下尾风CSS上提到的步骤遵循: NPM安装-D tailwindcss Postcss autoprefixer
进而 NPX TailWindCSS INIT -P
随后,我在tailwindconfig中添加了以下语句:
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
后来将以下内容添加到index .css
@tailwind base;
@tailwind components;
@tailwind utilities;
我的app.js看起来如下:
import './index.css'
function App() {
return (
<div className="App">
<h1 className='text-orange-500' >Navbar</h1>
</div>
);
}
export default App;
I am trying to create a react website usingnpx create-react-app myapp
cd my app
later i followed the steps as per mentioned on tailwind css that are as followed:npm install -D tailwindcss postcss autoprefixer
and thennpx tailwindcss init -p
followed by this i added the following statement to tailwindconfig:
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
later added the following to index .css
@tailwind base;
@tailwind components;
@tailwind utilities;
my app.js looked like following:
import './index.css'
function App() {
return (
<div className="App">
<h1 className='text-orange-500' >Navbar</h1>
</div>
);
}
export default App;
still the tailwind is not taking any affect please help
folder structure is as followed;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现这个问题是在尾风配置中,并且我删除了Postcss文件。新的尾风配置:
这对我有用
I have found the issue the issue was in tailwind config and along with that i deleted the postcss file. The new tailwind config:
this worked for me still i am confused over the fact why it happened but anyways its working now
您可能会遇到tailwind.config.js的问题,您可以尝试以下tailwind.config.js,在Create React应用中,组件存储在SRC目录中,并且您的目标是针对页面和组件目录,因此请与.src一起使用.src /pages//,.src/pages/,.src/components//, .src/组件/,可以使用您,请尝试一下。
You might be having issue with tailwind.config.js can you try the below tailwind.config.js, In Create React App, the components are stored in src directory and you are targeting specific to pages and components directory, so going with .src/pages//, .src/pages/, .src/components//, .src/components/, may work you, Give it a try.
在项目 root 中创建一个.postCSSRC文件
Create a .postcssrc file in your project root