再好的烤串也需要有個盒子裝
想象一下你有一間木屋燒烤的店面,
紅圈圈是店面的一桌客人
客人提出:服務員,XXXX的烤串(例如:面筋要放在一個精制的盤子上,我還要分開出來,我吃面筋,不喜歡串味)


用烤串的思考模式來看待自定義模塊設計
https://www.bilibili.com/read/cv22839127(最最粗暴的上菜)
精制的上菜,這個面筋用盤子裝起來:

告訴客人,菜來了

babiq寫的是什么:

相關代碼如下:babiq
function formatApi(api) {
? ?return "http://www.happy study.com/"+api;
}
exports.formatApi=formatApi;
--------------------------------------------------
相關代碼如下:1.js
const http=require('http');
const tools=require('./babiq.js');
//(菜單1:面筋)
console.log(tools);
http.createServer((req,res)=>{
? ?res.writeHead(200,{'Content-Type':"text/html;charset='utf-8'"});
? ?res.write("<head><meta charset='UTF-8'></head>");
? ?var api=formatApi('api/plist');
? ?res.write('你好哇~來學習呀');
? ?res.write(api);
? ?res.end();
}).listen(5000);

--------------------------------------------------------
火眼金睛:
const http=require('http');
const tools=require('./babiq.js');
//(菜單1:面筋)
console.log(tools);
http.createServer((req,res)=>{
? ?res.writeHead(200,{'Content-Type':"text/html;charset='utf-8'"});
? ?res.write("<head><meta charset='UTF-8'></head>");
?
? ?res.write('你好哇~來學習呀');
? ?var api=tools.formatApi('api/我已經發(fā)生銜接');
? ?res.write(api);
? ?res.end();
}).listen(5000);

