企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
使用 maps 比使用多个不同的变量有明显优势。最重要的优势就是 map 的遍历功能,这在多个不同变量中是不可能实现的。 另一个支持使用 map 的原因,是它可以创建 `map-get()` 函数以提供友好 API 的功能。比如,思考一下下述 Sass 代码: ~~~ /// Z-indexes map, gathering all Z layers of the application /// @access private /// @type Map /// @prop {String} key - Layer's name /// @prop {Number} value - Z value mapped to the key $z-indexes: ( 'modal': 5000, 'dropdown': 4000, 'default': 1, 'below': -1, ); /// Get a z-index value from a layer name /// @access public /// @param {String} $layer - Layer’s name /// @return {Number} /// @require $z-indexes @function z($layer) { @return map-get($z-indexes, $layer); } ~~~