CSS - 妙用Sass

打印 上一主题 下一主题

主题 890|帖子 890|积分 2672

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

  1. @each $theme in $themeList {
  2.   $themeKey: map-get($theme, 'key');
  3.   @media screen and (weex-theme: $themeKey) {
  4.     .btnText {
  5.       max-width: 150px;
  6.       @include font(map-get($theme, 'medFont'),map-get($theme, 'subFontSize'),400);
  7.       @include ellipsis(2);
  8.       color: map-get($theme, 'whiteColor');
  9.       text-align: center;
  10.     }
  11.   }
  12. }
  13. /**
  14. @each $theme in $themeList:
  15. 这是一个循环语句,遍历$themeList中的每个主题。
  16. $themeList通常是一个包含多个主题的列表,每个主题是一个映射(map)。
  17. $themeKey: map-get($theme, 'key'):
  18. 从当前主题映射中获取键值为'key'的值,并将其赋值给$themeKey。
  19. map-get是Sass中的一个函数,用于从映射中获取值。
  20. @media screen and (weex-theme: $themeKey):
  21. 这是一个媒体查询,用于根据不同的主题键值应用不同的样式。
  22. weex-theme是一个自定义的媒体查询特性,用于在Weex中切换主
  23. */
复制代码


  • 【逐步分析】
    xx组件:
  1. <style lang="scss" scoped>
  2. @import './config.scss';
  3. @each $theme in $themeList {
  4.   $themeKey: map-get($theme, 'key');
  5.   @media screen and (weex-theme: $themeKey) {
  6.     .btnText {
  7.       max-width: 150px;
  8.       @include font(map-get($theme, 'medFont'),map-get($theme, 'subFontSize'),400);
  9.       @include ellipsis(2);
  10.       color: map-get($theme, 'whiteColor');
  11.       text-align: center;
  12.     }
  13.   }
  14. }
  15. </style>
复制代码
config.scss:
  1. @charset "UTF-8";
  2. @import '../../../css/uiStandard/scss/default.scss';
  3. $themeList: $mideaO100, $default;
复制代码
default.scss:
  1. @charset "UTF-8";
  2. $default:(
  3.   key: 'default',
  4.   bigBtnHeight: 92px,
  5. );
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

南七星之家

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表