我正在开发一个项目,其中一个手写笔文件应该根据 Javascript 代码中定义的变量输出不同的 CSS。我发现the Javascript API但无法找到一种干净且好的方法来以编程方式设置变量。
有人知道如何使用 Node.js 在 Stylus 中设置颜色变量并返回 CSS 吗?
最佳答案
类似于:
var stylus = require('stylus');
stylus('body\n color: some-color')
.define('some-color', new stylus.nodes.RGBA(128, 128, 128, 1)) // #808080
.render(function(err, css) {
if (err) throw err;
console.log(css);
});
参见lib/nodes/rgba.js和 lib/nodes/hsla.js .
我想你也可以使用json bif完成您的任务。
关于stylus - 以编程方式设置手写笔变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30295699/