[英]Unable to import TailwindCSS
I'm trying to import TailwindCSS but it does not seem to work as no CSS is applied.我正在尝试导入 TailwindCSS,但它似乎不起作用,因为没有应用 CSS。
I have it in my package.json
:我在我的
package.json
中有它:
"devDependencies": {
"autoprefixer": "^10.2.4",
"css-loader": "^5.1.1",
"postcss": "^8.2.7",
"style-loader": "^2.0.0",
"tailwindcss": "^2.0.3"
}
I have installed it via npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
.我已经通过
npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
安装了它。
Index:指数:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import MenuAppBar from './header';
import reportWebVitals from './reportWebVitals';
import Tail from './App';
ReactDOM.render(
<React.StrictMode>
<MenuAppBar />
<Tail />
</React.StrictMode>,
document.getElementById('root')
);
App looks like this:应用看起来像这样:
import "tailwindcss/tailwind.css"
export default function Tail(){
return (
<div class="chat-notification">
<div class="chat-notification-logo-wrapper">
<img class="chat-notification-logo" src="/img/logo.svg" alt="ChitChat Logo"></img>
</div>
<div class="chat-notification-content">
<h4 class="chat-notification-title">ChitChat</h4>
<p class="chat-notification-message">You have a new message!</p>
</div>
</div>
)
}
Sometimes it takes some playing around with the imports and reviewing in detail everything you write, this happens to me so often and its usually just a really small type error that creates this.有时需要花费一些时间来处理导入并详细审查您编写的所有内容,这种情况经常发生在我身上,通常只是一个非常小的类型错误导致了这种情况。 check out your first import in your App file.
在您的 App 文件中检查您的第一次导入。 i noticed at the top it says "import "tailwindcss/tailwind.css"" try adding a "./" before tailwind.
我注意到在顶部它说“导入“tailwindcss/tailwind.css””尝试在顺风之前添加一个“./”。 so it ends uo looking like this
所以它结束了你看起来像这样
import "./tailwindcss/tailwind" If you are using vscode it helps when you begin typing the./ when importing files becasue the pop-up displays the files you have in that immediate path. import "./tailwindcss/tailwind" 如果您使用的是 vscode,则在导入文件时开始键入 ./ 会有所帮助,因为弹出窗口会显示您在该直接路径中拥有的文件。
I also recommend installing the automatic import extension, it helps alot, I hope this work.我还建议安装自动导入扩展,它有很大帮助,我希望这能奏效。 cheers.
干杯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.