在less里面使用js函数

.colorPaletteMixin() {
  @functions: ~`(function() {
    
  
    this.colorPalette = function() {
      return '123px';
    };
  })()`;
}
// It is hacky way to make this function will be compiled preferentially by less
// resolve error: `ReferenceError: colorPalette is not defined`
// https://github.com/ant-design/ant-motion/issues/44
.colorPaletteMixin();

.test {
  width: `colorPalette()`;
}

 

posted on 2020-07-17 10:06  chen8840  阅读(3138)  评论(0编辑  收藏  举报