LESS 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

字符串函数

escape

对字符串中的特殊字符做 URL-encoding 编码。

  这些字符不会被编码:,, /, ?, @, &, +, ', ~, ! and $

  被编码的字符是:\, #, ^, (, ), {, }, |, :, >, <, ;, ], [ and =

escape('a=1') // return a%3D1

% 格式化

此函数 %(string, arguments ...) 用于格式化字符串。

format-a-d: %("repetitions: %a file: %d", 1 + 2, "directory/file.less");

输出:

format-a-d: "repetitions: 3 file: "directory/file.less"";

replace

用一个字符串替换一段文本。

replace("Hello, Mars?", "Mars\?", "Earth!");

输出:

"Hello, Earth!";