我正在开发一个安装了 Tailwind CSS V3 的 Angular 16 项目。我已经遵循了官方文档,看起来一切正常;但我不明白为什么有些课程有效而其他课程无效。
例如,我可以有这段代码,尝试设置我的测试的颜色:
<div class="text-red-500 font-bold">
this text is supposed to be red and bold
</div>
显示的文本将具有粗体字体粗细,但颜色不会是红色,我总是必须使用传统的 scss 对其进行编辑 感谢您查看此内容。
我添加了 styles.scss 、 tailwind.config 和 package.json 的代码
样式.scss
@tailwind base;
@tailwind components;
@tailwind utilities;
@import url('https://fonts.googleapis.com/css2family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,300&display=swap');
:root {
--gray-color: #979797;
--primary-green: #05bf95;
}
Tailwind config file:
module.exports = {
content: [
"./src/**/*.{html,ts}",
],
theme: {
extend: {},
},
plugins: [
],
}
package.json 文件:
{
"name": "position-web",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test --no-watch --no-progress --code-coverage",
"lint": "ng lint",
"pretty-quick": "pretty-quick"
},
"private": true,
"dependencies": {
"@angular/animations": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"@ngrx/effects": "^16.0.1",
"@ngrx/entity": "^16.0.1",
"@ngrx/router-store": "^16.0.1",
"@ngrx/store": "^16.0.1",
"@ngrx/store-devtools": "^16.0.1",
"ngx-translate-multi-http-loader": "^16.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.0.5",
"@angular-eslint/builder": "^16.0.3",
"@angular-eslint/eslint-plugin": "^16.0.3",
"@angular-eslint/eslint-plugin-template": "^16.0.3",
"@angular-eslint/schematics": "^16.0.3",
"@angular-eslint/template-parser": "^16.0.3",
"@angular/cli": "~16.0.5",
"@angular/compiler-cli": "^16.0.0",
"@types/geojson": "^7946.0.10",
"@types/jasmine": "~4.3.0",
"@types/maplibre-gl": "^1.14.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"autoprefixer": "^10.4.14",
"daisyui": "^3.0.23",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-ngrx": "^2.1.4",
"eslint-plugin-prettier": "^4.2.1",
"i": "^0.3.7",
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"postcss": "^8.4.24",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"tailwindcss": "^3.3.2",
"typescript": "~5.0.2"
}
}
最后我找到了解决方案,我的代码被Daisy Ui覆盖了。卸载后,一切开始正常
就我而言,我的角度项目使用 scss。所以我删除了scss并将所有scss文件转换为CSS。然后就可以正常工作了。