classNames、immutability-helper、less的使用

189 阅读1分钟
  1. classNames
  • classNames()
const bottomCardSty=classNames({
  [styles.ownBHeight]: true,
  [styles.isBChecked]: checked,
  [styles.noBChecked]: !checked,
  [styles.noBCheckedMq]:!checked&&dataSet.dsCodeType==3,
})
  • classNames.bind()
const cx=classNames.bind(styles);
const topCardSty=cx({
  ownHeight: true,
  isChecked: checked,
  noChecked: !checked,
  noCheckedMq:!checked&&dataSet.dsCodeType==3,
})
  1. immutability-helper
//set 嵌套设值
update(chart, {
  option: {
    [axisType]: {
      [type]: {
        fontSize: { $set: num }
      }
    }
  }
})

//merge 合并对象
 update(seriesItemTemplate.data, {
  $merge: editSeriesItem.data
})
  1. less
@basicHeight:50vh;
@openEditorMarginLeft:160px;

.ownHeight{
  height:@basicHeight
}
.isChecked{
  height:@basicHeight
}
.noChecked{
  height: calc(@basicHeight - 38vh)
}
.noCheckedMq{
  height: calc(@basicHeight - 30vh)
}