获取图片

var readDir = require('readdir');
var fs = require('fs');

function getImages(){
var imgarr = [];

imgarr = readDir.readSync('images');
return imgarr;
}


function writeFile(){
var imgarr = getImages();
fs.writeFile('imglist.js',imgarr,function(err){
if(err) throw err;
console.log('生成文件成功')
})
}

writeFile();

posted on 2016-06-14 18:37  什么嘉  阅读(138)  评论(0编辑  收藏  举报

导航