问题
I want to call LESS's darken()
function on whatever the current color is (I don't have the current color in any variable). Is that possible?
回答1:
as per seven-phases-max request; in your node backend let say express
var less = require('less'); //also the body parser, express, etc
....
from your page you make an asynchronous request with the actual color of your page, just grabbing it with js and making the request. then in express:
app.post('/whateveryourroute', function(req, res) {
var colorFromReq = req.body.color;
less.render('.class { color: darken(`colorFromReq`, 20%) }', function (e, css) {
res.header("Content-type", "text/css");
res.send(css);
});
});
Something like that would be, didnt test it, but is possible.
来源:https://stackoverflow.com/questions/25451737/less-darken-on-current-color