相关文章推荐
憨厚的烈马  ·  vue3 monoca-editor ...·  昨天    · 
礼貌的米饭  ·  nodejs ...·  11 小时前    · 
稳重的刺猬  ·  node.js 设置header请求头 - ...·  11 小时前    · 
正直的大蒜  ·  Android ...·  7 月前    · 
路过的毛衣  ·  lua获取参数的方式_lua ...·  1 年前    · 
风流倜傥的葡萄酒  ·  html5 ...·  1 年前    · 
首发于 朝花夕拾

node.js获取目录下的所有文件

const fs=require('fs')
const path=require('path')
function getFiles(dir){
    const stat=fs.statSync(dir)
    if(stat.isDirectory()){
      //判断是不是目录
      const dirs=fs.readdirSync(dir)
      dirs.forEach(value=>{
         // console.log('路径',path.resolve(dir,value));
          getFiles(path.join(dir,value))