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,
);
相关推荐
勤奋的懒洋洋3505 分钟前
前端实现多个图片打包下载
前端
豐儀麟阁贵18 分钟前
9.5格式化字符串
java·开发语言·前端·面试
春生野草24 分钟前
Ruoyi前端基于vue的脚手架的目录解析
前端·javascript·vue.js
m0_7400437336 分钟前
Axios拦截器 -- 请求拦截器和响应拦截器
开发语言·前端·javascript
不会代码的小猴1 小时前
C++的第十一天笔记
java·前端·jvm
风止何安啊1 小时前
递归 VS 动态规划:从 “无限套娃计算器” 到 “积木式解题神器”
前端·javascript·算法
ohyeah1 小时前
使用 Vue 3 实现大模型流式输出:从零搭建一个简易对话 Demo
前端·vue.js·openai
GPTMirrors镜像系统1 小时前
JS 实现指定 UA 访问网站跳转弹窗提醒,解决夸克等浏览器兼容性问题
前端·javascript
踢球的打工仔2 小时前
前端html(2)
前端·算法·html
Rysxt_2 小时前
Vue文件下载功能完整指南:从基础实现到进阶实战
前端·javascript·vue.js