1.文件導(dǎo)出模塊
function add(a,b){
return a+b;
}
module.exports=add;
2.在其他文件中導(dǎo)入模塊
const add=require("./a");
3.導(dǎo)出和導(dǎo)入多個模塊
導(dǎo)出:module.exports={ xx,yy}
導(dǎo)入:const { xx,yy}=require("./a")
1.文件導(dǎo)出模塊
function add(a,b){
return a+b;
}
module.exports=add;
2.在其他文件中導(dǎo)入模塊
const add=require("./a");
3.導(dǎo)出和導(dǎo)入多個模塊
導(dǎo)出:module.exports={ xx,yy}
導(dǎo)入:const { xx,yy}=require("./a")