动态改变较少的变量 [英] Dynamically changing less variables

查看:165
本文介绍了动态改变较少的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在客户端更改较少的变量。
假设我的文件较少

I want to change a less variable on client side. Say I have a less file

@color1: #123456;
@color2: @color1 + #111111;

.title { color: @color1; }
.text { color: @color2; }

我希望该用户选择一种颜色并更改@ color1的值并重新编译css而不重新加载页面。

I want that user yo pick a color and change the value of @color1 and recompile css without reloading the page.

基本上我正在寻找一个js函数,类似这样的事情

Basically I'm looking for a js function, something like this

less_again({color1: '#ff0000'}) 


推荐答案

less.js的创建者添加了一些功能,可以让你做这样的事情。阅读评论和答案:动态加载less.js规则

The creator of less.js added some features that should allow you to do something like this. Read the comments and the answers here: Load less.js rules dynamically

这篇关于动态改变较少的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆