Scss, is used in vue components to use components in different situations. How can the value of the style be written?

when components are introduced in different places, the sizes of components are different, and all other styles are the same. Could you tell me how to use scss? at this time?

Mar.05,2021

you can use

in the component

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

props:['newStyle']
data(){
 return {
  style:{
      ....
      }
 },
 created() {
  this.style = Object. assign({},this.newStyle,this.style)
 }
}

define style bindings when writing components

example: class= "xxx==1?bigClass:smallClass" component

introduce the value of determining xxx to determine the style

the problem with values is that component communication is not detailed


provides ideas: receive: size, in the component and transfer the size in the parent component;


Why not props to do it? It feels best to pass props to different styles


props to accept style parameters. Super highly customizable


iview button components you can refer to
`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)
}

]; `

Menu