我使用faker.js https://www.npmjs.com/package/faker生成随机数据。虽然当我尝试创建像这样的路径时,它工作得很好
faker.system.directoryPath() + '/' + faker.system.filePath()在这两种情况下,我都有未定义的,因此它似乎存在,但不返回任何内容。
以前有人用过这些方法吗?
事先谢谢,任何帮助都会非常感谢。
再见
发布于 2016-10-10 14:33:37
这些功能没有实现--看看https://github.com/Marak/faker.js/blob/master/lib/system.js#L132和https://github.com/Marak/faker.js/blob/master/lib/system.js#L141
/**
* not yet implemented
*
* @method faker.system.filePath
*/
this.filePath = function () {
// TODO
};关于如何实施这一概念的一些证明:
var faker = require('faker');
var path = require('path');
faker.directoryPath = function() {
return path.format({base: faker.fake("{{random.words}}").replace(/ /g, path.sep).toLowerCase()})
}
console.log(faker.directoryPath() + path.sep + faker.system.fileName()) // e.g. avon\re-engineered\strategist_gorgeous_wooden_fish_cambridgeshire.smhttps://stackoverflow.com/questions/39960242
复制相似问题