简体   繁体   English

如何在 Angular 项目中使用 @apply (Tailwind) 添加自定义 class?

[英]How to add custom class to with @apply (Tailwind) in Angular project?

Image图片

Hi everyone, I have error in css file, with custorm tailwind class. How to fix it?大家好,我在 css 文件中有错误,custorm tailwind class。如何解决?

/** @type {import('tailwindcss').Config} */

module.exports = {
  content: ['./src/**/*.{html,ts}'],
  theme: {
    extend: {},
  },
  plugins: [],
}

Image图片

If I delete focus:shadow-outline code, it's begin working如果我删除focus:shadow-outline代码,它就会开始工作

shadow-outline is a custom class. shadow-outline是自定义的 class。

You must first define it before using it like this:您必须先定义它,然后再像这样使用它:

@layer components {
  .shadow-outline {
    @apply w-auto /*some classes*/;
  }
  .button {
    @apply block uppercase mx-auto shadow bg-indigo-800 hover:bg-indigo-700 focus:shadow-outline focus:outline-none text-white text-xs py-3 px-10 rounded;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM