Closed tces1 closed 8 years ago
save
是 同步操作
save: function(file, type, config) {
if (type && typeof(type) == "object") {
config = type;
type = undefined;
}
fs.writeFileSync(file, this.encode(type || path.extname(file), config));
}
如果一定要异步。可以用这个:
saveAsync: function (file, type, config, callback) {
if (type && typeof(type) === 'object') {
config = type;
type = undefined;
}
if (!callback) {
if (typeof type === 'function') {
callback = type;
type = undefined;
}
if (typeof config === 'function') {
callback = config;
config = undefined;
}
}
fs.writeFile(file, this.encode(type || path.extname(file), config), callback);
return this;
}
thx ^_^
我也遇到了同样的问题!