简体   繁体   English

我如何使用 Vue 上的 Props 使用 class Tailwind

[英]How can i use class Tailwind using Props on Vue

i've tried to using reusable component on vue js like pass props class name.我尝试在 vue js 上使用可重用组件,例如传递道具 class 名称。 In my case, i'm using tailwind css, how can i pass class name using props.就我而言,我使用的是顺风 css,如何使用道具传递 class 名称。 Thanks guys, Have nice weekend:)谢谢大家,周末愉快:)

this is my html router tag这是我的 html路由器标签

router-link.button-filled(
 :to="routeName"
 :title="title"
 :class="customClass"
)
 | {{ title }}

this is my props这是我的道具

props: {
  routeName: { default: "/", type: String },
  title: { default: "Button", type: String },
  size: { default: "md", type: String },
  backgroundColor: { default: "red-500", type: String },
  borderColor: { default: "red-500", type: String }
},

this is my computed这是我的计算

computed: {
  customClass() {
    return [
      "fst-bg-" + this.backgroundColor,
      "fst-border-" + this.borderColor
    ];
  }
}

已加载此类,但未应用样式

how's good?怎么样?
Do you really need this 'fst' prefix?你真的需要这个'fst'前缀吗?

If so, you'll need to configure this fst as a prefix in the tailwind.config.js file, to do so you can check this part of the doc:如果是这样,您需要将此 fst 配置为tailwind.config.js文件中的前缀,为此您可以检查文档的这一部分:
#Tailwind prefix #顺风前缀

But If you want to use custom colors instead you'd want to checkout this part of doc:但是,如果您想使用自定义 colors 代替,您需要查看文档的这一部分:
#Tailwind custom colors #顺风定制 colors

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

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