简体   繁体   English

SassError: 未能@extend class: 顺风 vue 无法将多个顺风类合并到一个自定义 class

[英]SassError: failed to @extend class: tailwind vue can't unite several tailwind classes into a single custom class

I have a vue component that looks like this:我有一个看起来像这样的vue组件:

<template>
    <ul class="list-reset flex justify-between flex-1 md:flex-none items-center">
        <li class="flex-1 md:flex-none md:mr-3
                    sm:text-xs md:text-xs lg:text-xs xl:text-sm">
            <a class="inline-block py-2 px-4
                    text-white no-underline" href="#">Link1</a>
        </li>

        <li class="flex-1 md:flex-none md:mr-3
                    sm:text-xs md:text-xs lg:text-xs xl:text-sm">
            <a class="inline-block py-2 px-4
                    text-white no-underline" href="#">Link2</a>
        </li>

       ...

  </ul>
</template>

As can be seen, all navbar links have the same tailwind classes.可以看出,所有导航栏链接都具有相同的顺风类。 I want to unite all those classes into a single class navbar-item .我想将所有这些类合并到一个 class navbar-item中。 I tried to add the following to the .vue file:我尝试将以下内容添加到.vue文件中:

<style lang = "scss" scoped>
    @import "../assets/css/tailwind.css";
    @import "../assets/css/style.css";

    .navbar-item {
        @extend .flex-1, .md\:flex-none, .md\:mr-3,
            .sm\:text-xs, .md\:text-xs, .lg\:text-xs, .xl\:text-sm;
     }
</style>

However I get the但是我得到了

SassError: ".navbar-item" failed to @extend ".flex-1".

error.错误。

I'm not sure how to fix it.我不知道如何解决它。 Any help is appreciated.任何帮助表示赞赏。

Use @apply to inline any existing utility classes into your own custom CSS.使用@apply将任何现有实用程序类内联到您自己的自定义 CSS 中。 Check docs检查文档

eg例如

/* Won't work: */
.btn {
  @apply block bg-red-500;
  @apply hover:bg-blue-500;
  @apply md:inline-block;
}

/* Do this instead: */
.btn {
  @apply block bg-red-500;
}
.btn:hover {
  @apply bg-blue-500;
}
@screen md {
  .btn {
    @apply inline-block;
  }
}

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

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