顺风在规则中添加@顺风css,标记为未知。 如何避免这种错误?
如styles.css
@tailwind起飞前的;
@tailwind公用事业;
顺风在规则中添加@顺风css,标记为未知。 如何避免这种错误?
如styles.css
@tailwind起飞前的;
@tailwind公用事业;
当前回答
当前推荐的VS代码设置(更新于2022年12月15日)
官方顺风CSS智能感知VS文档
使用这些文件。associations设置告诉VS Code总是在顺风CSS模式下打开。CSS文件:
"files.associations": {
"*.css": "tailwindcss"
}
提示:按Ctrl +,从VS Code打开设置;然后,输入“Files Associations”。
默认情况下,VS Code在编辑“字符串”内容时不会触发补全,例如在JSX属性值中。更新编辑器。quickrecommendations设置可以改善您的体验:
"editor.quickSuggestions": {
"strings": true
}
结合两者,你的设置。Json文件(如果是新的)将看起来像这样:
{
"files.associations": {
"*.css": "tailwindcss"
},
"editor.quickSuggestions": {
"strings": true
}
}
来源:https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
以前推荐的VS代码设置(已弃用)
VS Code有内置的CSS验证,当使用tailwind特定的语法时可能会显示错误,比如@apply。你可以在css中禁用它。验证设置:
"css.validate": false
“编辑器。quickrecommendations”设置建议保持不变。结合两者,你的设置。Json文件(如果是新的)看起来类似这样:
{
"css.validate": false,
"editor.quickSuggestions": {
"strings": true
}
}
其他回答
这是vscode内置列表提供的at-rule-no-unknown规则。
为了摆脱它,你需要做以下事情:
1. 安装styelint扩展代码——Install -extension styelint . vcode - styelint
2. 安装styelint推荐配置
3.在vscode USER SETTINGS中添加这两行
"css.validate": false, // Disable default css built-in lint
"stylelint.enable": true, // Enable stylelint
"scss.validate": false, // Disable scss lint (optional if using scss)
4. 将这些行粘贴到项目根目录中名为.stylelintrc的文件中,如果它不存在,则创建它。更多关于stylelint配置的信息请访问这个链接:https://stylelint.io/user-guide/
{
"extends": "stylelint-config-recommended",
"rules": {
"at-rule-no-unknown": [ true, {
"ignoreAtRules": [
"extends",
"tailwind"
]
}],
"block-no-empty": null,
"unit-allowed-list": ["em", "rem", "s"]
}
}
在这里输入图像描述 对于Vue 3,您可能尝试安装Vue 3支持扩展
根据tailwindcss-intellisense github库:
VS代码推荐设置
files.associations
使用这些文件。associations设置告诉VS Code总是在顺风CSS模式下打开。CSS文件:
"files.associations": {
"*.css": "tailwindcss"
}
它修复了@顺风警告,并增加了顺风指令,功能的智能感知
关于tailwindcss智能感知扩展的更多信息可以找到 在github存储库
只需在设置中添加三行。json文件
"css.lint.unknownAtRules": "ignore",
"css.validate": true,
"scss.validate": true,
我的建议是安装postCSS语言支持,然后重命名tailwind.css为tailwind。然后PCSS更改包中的引用。Json脚本(或任何构建脚本你正在使用顺风)顺风。PCSS从顺风。css和一切应该工作正常。
@apply规则兼容postCSS: https://github.com/tailwindcss/tailwindcss/issues/325