鍍金池/ 問答/HTML/ vue組件中使用scss,在不同的情況下使用組件,樣式的值可以變怎么寫?

vue組件中使用scss,在不同的情況下使用組件,樣式的值可以變怎么寫?

不同的地方引入組件的時候,組件的大小有些不同,其他樣式都是一樣的。請問這個時候應該怎么使用scss?

回答
編輯回答
初心

iview button 組件 你可以參考一下
`classes () {
return [

`${prefixCls}`,
{
  [`${prefixCls}-${this.type}`]: !!this.type,
  [`${prefixCls}-long`]: this.long,
  [`${prefixCls}-${this.shape}`]: !!this.shape,
  [`${prefixCls}-${this.size}`]: !!this.size,
  [`${prefixCls}-loading`]: this.loading != null && this.loading,
  [`${prefixCls}-icon-only`]: !this.showSlot && (!!this.icon || this.loading)
}

];`

2018年1月10日 17:08
編輯回答
瘋浪

props接受style參數(shù)感覺是最好的。超高度可定制化

2018年2月20日 02:53
編輯回答
幼梔

為什么不用props來做呢? 通過傳遞的props去給不同的樣式

2017年9月19日 11:19
編輯回答
放開她

你可以在組件中

<Item :style="style"></Item>

props:['newStyle']
data(){
 return {
  style:{
      ....樣式
      }
 },
 created() {
  this.style = Object. assign({},this.newStyle,this.style)
 }
}
2017年11月13日 02:34
編輯回答
涼心人

寫組件時候 定義一下樣式綁定

舉例子 :class="xxx==1?bigClass:smallClass" 組件

引入 確定xxx的值來決定樣式

至于值的問題 就是組件通信 不細說

2017年7月27日 12:18
編輯回答
有你在

提供思路:在組件里接收:size , 在父組件里把尺寸傳進去;

2018年6月7日 06:35