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,
);
相关推荐
小妖66628 分钟前
css3的transform:tanslateZ没有效果
前端·css·css3
见青..1 小时前
[BUUCTF]web--wp(持续更新中)
前端·web安全·网络安全
二川bro1 小时前
前端模块化管理深度解析:从混沌到秩序的全链路实践指南
前端
JosieBook1 小时前
【前端】在WebStorm中安装Node.js与nvm与npm的详细过程
前端·node.js·webstorm
linweidong1 小时前
希音(Shein)前端面试题集锦和参考答案
前端·arcgis·xss·csrf·前端面试·前端面经·webpack原理
桃子不吃李子1 小时前
npm ERR! code 128 npm ERR! An unknown git error occurred
前端·npm·node.js
思想永无止境1 小时前
解决windows npm无法下载electron包的问题
前端·electron·npm
2401_897930061 小时前
npm install 详解
前端·npm·node.js
uhakadotcom3 小时前
React Flow:可视化流程管理的利器
前端·面试·github
木辰風3 小时前
vue These dependencies were not found
前端·javascript·vue.js