![](/img/trans.png)
[英]JavaScript export array from one file to another to be used. Node.js
[英]how to export a function from one file to another node.js?
我有一些需要從另一個文件訪問的功能。 但由於某種原因,我做不到。
creatureScreenfunction (dir, jsonFile, pathToFile){
let Mode = require('stat-mode');
let temp;
fs.readdir(dir, function(err, items)
.............................................
}
這是我嘗試過的
exports.creatureScreen = creatureScreen();
在第二個文件中
const index = require("../index.js");
你在這里做了什么exports.creatureScreen = creatureScreen();
名為導出。 在其他文件中導入它時,您需要執行const {creatureScreen} = require("../index.js");
.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.