当前位置: 首页 > 知识库问答 >
问题:

Tailwind的指令@apply不在Nuxt上工作

鞠凌龙
2023-03-14

我正在尝试在我全新的项目中使用TailWind,每个应用程序都很好,但是@应用程序甚至不能编译。

以下是错误消息:

Syntax Error: SyntaxError                                                                                                                                                                                                                                       friendly-errors 08:12:30

(5:5) `@apply` cannot be used with `.lg\:mt-0` because `.lg\:mt-0` either cannot be found, or its actual definition includes a pseudo-selector like :hover, :active, etc. If you're sure that `.lg\:mt-0` exists, make sure that any `@import` statements are being properly processed *before* Tailwind CSS sees your CSS, as `@apply` can only be used for classes in the same CSS tree.

  3 | @import 'tailwindcss/components';
  4 | .navbar-item-link {
> 5 |     @apply text-xs mt-1 lg:mt-0 px-3 no-underline text-gray-600 rounded-full border-solid border border-gray-100 hover:border-blue-best-100;
    |     ^
  6 | }
  7 | /* purgecss end ignore */

我的顺风。css文件:

/* purgecss start ignore */
@import 'tailwindcss/base';
@import 'tailwindcss/components';
.navbar-item-link {
    @apply text-xs mt-1 lg:mt-0 px-3 no-underline text-gray-600 rounded-full border-solid border border-gray-100 hover:border-blue-best-100;
}
/* purgecss end ignore */

@import 'tailwindcss/utilities';

我已经安装了POSTSS cli并使用POSTSS。配置。就像这样:

module.exports = {
  plugins: [
    require("postcss-import"),
    require("tailwindcss"),
    require("autoprefixer")
  ]
};

但这些都不管用。

共有1个答案

晏昀
2023-03-14

不能将伪类前缀与@apply方法一起使用

而不是这个

.navbar-item-link {
    @apply text-xs mt-1 lg:mt-0 px-3 no-underline text-gray-600 rounded-full border-solid border border-gray-100 hover:border-blue-best-100;
}

你应该使用这样的东西:

// Normal State
.navbar-item-link {
    @apply text-xs mt-1 px-3 no-underline text-gray-600 rounded-full border-solid border border-gray-100;
}

// Hover State
navbar-item-link:hover{
    @apply border-blue-best-100;
}

// Large Screen
@screen lg {
    .navbar-item-link{
        @apply mt-0;
    }
}

这里有更多关于它的信息

https://tailwindcss.com/docs/extracting-components/#extracting-带有apply的css组件

https://tailwindcss.com/docs/functions-and-directives/#screen

 类似资料:
  • 问题内容: 如果我有一个指令可以响应示波器上特定属性的状态,并且我想在测试中更改该属性并验证其是否正确响应,那是进行此更改的最佳方法? 我已经看过这两种模式: 和 它们之间有什么区别,哪个更好,为什么? 问题答案: 会在当前范围及其所有子级上触发监视程序。将评估传递的函数并运行。 第一个更快,因为它需要评估观察者的当前范围及其子级。第二个比较慢,因为它需要评估观察者及其所有子作用域。 当其中一个观

  • 从git在Angular 4 cli中创建指令 /Angular/projectName$ng生成指令DirectiveName 应该管用 [注意:DirectiveName是唯一的,与组件名称或模块名称不匹配] 但我犯了一个错误 错误:多个模块匹配。使用跳过导入选项跳过将组件导入最近的模块。多个模块匹配。使用跳过导入选项跳过将组件导入最近的模块。

  • 在一次采访中,有人问我是否知道x64指令的行为因所使用的CPU而异,我无法在任何地方找到任何文档,有谁知道这些指令是什么以及为什么会这样?

  • 我正在用一个指令计算html元素的最小高度,当我试图通过scope.$apply()更新父作用域值时,我得到以下错误: 我的指示是: 我总是可以使用更新父作用域值,但在这种情况下,指令的作用域规则将不起作用(例如,如果我想通过“@”隔离作用域,则ctrl仍将接收更新)。 此外,我可以通过设置min-height值,但我希望以角度的方式进行。 问题出在哪里? *使用angular 1.3.5处理任何

  • @tailwindcss base导入了哪些基础样式?从哪里(代码库中的哪个或哪些文件)可以获知?还是说它并没有导入任何样式,但是我们可以通过以下方式声明一些样式,然后这些样式按照@tailwindcss的声明顺序来应用。

  • @nativescript/tailwind Makes using Tailwind in NativeScript a whole lot easier! <label text="TailwindCSS is awesome!" class="px-2 py-1 text-center text-blue-600 bg-blue-200 rounded-full"/> Usage (wi