我需要使用 Node.js 从目录中读取文件,文件名都是 .json 如何在 Node.js 中对文件名部分使用通配符?
您可以使用glob npm用于使用通配符文件名模式匹配
var glob = require("glob")
// options is optional
glob("DIR_PATH/*.json", options, function (er, files) {
// files is an array of filenames.
// er is an error object or null.
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)