CSS - 妙用Sass

官方文档:https://www.sass.hk/docs/

1.例1:

bash 复制代码
@each $theme in $themeList {
  $themeKey: map-get($theme, 'key');
  @media screen and (weex-theme: $themeKey) {
    .btnText {
      max-width: 150px;
      @include font(map-get($theme, 'medFont'),map-get($theme, 'subFontSize'),400);
      @include ellipsis(2);
      color: map-get($theme, 'whiteColor');
      text-align: center;
    }
  }
}
/**
@each $theme in $themeList:
这是一个循环语句,遍历$themeList中的每个主题。
$themeList通常是一个包含多个主题的列表,每个主题是一个映射(map)。

$themeKey: map-get($theme, 'key'):
从当前主题映射中获取键值为'key'的值,并将其赋值给$themeKey。
map-get是Sass中的一个函数,用于从映射中获取值。

@media screen and (weex-theme: $themeKey):
这是一个媒体查询,用于根据不同的主题键值应用不同的样式。
weex-theme是一个自定义的媒体查询特性,用于在Weex中切换主
*/
  • 【逐步分析】
    xx组件:
bash 复制代码
<style lang="scss" scoped>
@import './config.scss';

@each $theme in $themeList {
  $themeKey: map-get($theme, 'key');
  @media screen and (weex-theme: $themeKey) {
    .btnText {
      max-width: 150px;
      @include font(map-get($theme, 'medFont'),map-get($theme, 'subFontSize'),400);
      @include ellipsis(2);
      color: map-get($theme, 'whiteColor');
      text-align: center;
    }
  }
}
</style>

config.scss:

bash 复制代码
@charset "UTF-8";

@import '../../../css/uiStandard/scss/default.scss';
$themeList: $mideaO100, $default;

default.scss:

bash 复制代码
@charset "UTF-8";
$default:(
  key: 'default',
  bigBtnHeight: 92px,
);
相关推荐
蘑菇头爱平底锅几秒前
数字孪生-DTS-孪创城市-低空范围
前端·javascript·数据可视化
KenXu2 分钟前
Module Federation v0.12新特征详解
前端
三原15 分钟前
前端微应用-乾坤(qiankun)原理分析-沙箱隔离(css)
前端·架构·前端框架
琦遇17 分钟前
Vue3使用AntvG6写拓扑图,可添加修改删除节点和边
前端·javascript·vue.js
Luckyfif18 分钟前
🗣️面试官:有一个比较经典的 case 也想探讨一下 「页面白屏如何排查?」❤️✨
前端·面试·开源
爱上大树的小猪22 分钟前
【前端进阶】深入解析 Flexbox 布局中的 flex-shrink 与 gap 兼容性问题
前端·css·面试
南囝coding22 分钟前
做Docx预览,一定要做这个神库!!
前端·vue.js·面试
打野赵怀真22 分钟前
怎样提高微信小程序的渲染性能?
前端·javascript
邵洛24 分钟前
一、【UnoCss / unibest】样式篇
前端
Mike_jia25 分钟前
Wireshark 网络数据包分析全解:从抓包入门到企业级实战
前端