【发布时间】:2015-12-23 06:35:07
【问题描述】:
我想在我的手写笔中访问 javascript 值,我在下面这样做。此函数完美地输出值,但它没有更新我的 test.css 文件。
var config = {
sizes:{
width:"500px",
height:"200px"
},
background:"rgba(10,10,100)",
color:[100,10,10,.5],
someArray:[100,0,0,2]
};
var str = require('fs').readFileSync(__dirname+'/test.styl',{encoding:'utf8'});
var stylus = require('stylus');
var stylusVars = require('stylus-vars')(config,{delimiter:'-'});
// the delimiter option defines how nested objects will be represented
stylus(str)
.set('filename','test.css')
.use(stylusVars)
.render(function(err, css){
if(err){throw err;}
console.log(css);
});
stylus.set() 有什么作用?
【问题讨论】:
-
不应该写文件吗?
fs.writeFile('test.css', css)
标签: javascript css stylus