最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

2023.4.4的課程講義

2023-04-04 09:12 作者:燒串者  | 我要投稿

url怎么用
url是什么

url.parse----解析url



var url=require('url')
url.parse("網(wǎng)址")

網(wǎng)址:http://www.baidu.com
? ?var url=require('url')
? ?url.parse("http://www.baidu.com?name=good")
? ?url.parse("http://www.baidu.com?name=good",true)
--------------------------------------------
const url=require('url');
var api="http://www.baidu.com?name=nice&age=18";
console.log(url.parse(api));
// ?query: 'name=nice&age=18'
--------------------------------------------
//
const url=require('url');
var api="http://www.baidu.com?name=nice&age=18";
console.log(url.parse(api,true));
// query: [Object: null prototype] { name: 'nice', age: '18' },
//轉(zhuǎn)換成了對象!
-------------------------------------------
? ?//
學(xué)習(xí)這個:!
var getValue=url.parse(api,true).query;
console.log(getValue);


怎么寫:
const url=require('url');
var api="http://www.baidu.com?name=nice&age=18";
var getValue=url.parse(api,true).query;
console.log(getValue);
-------------------------------------------
//模板字符串
const url=require('url');
var api="http://www.baidu.com?name=nice&age=18";
var getValue=url.parse(api,true).query;
console.log(getValue);
console.log(`姓名:${getValue.name}---年齡:${getValue.age}`);



------------------------------------------
? ?作者:燒串者 https://www.bilibili.com/read/cv22828244?spm_id_from=333.999.0.0 出處:bilibili
const http=require('http');
http.createServer((req,res)=>{
? ? ? ?console.log(req.url);
? ? ? ?res.writeHead(200,{"Content-type":"text/html;charset='utf-8'"}); //解決亂碼

? ? ? ?res.write("<head> <meta charset='UTF-8'></head>"); ?//解決亂碼

? ? ? ?(?)

? ? ? ?res.end("中華民族偉大復(fù)興");
? ?}
).listen(3001);

console.log("server running at localhost:3001");




[-----------------------
? ?http://www.baidu.com?name=nice&age=18

? -------> 127.0.0.1?name=nice&age=18

? ?------------------------]

console.log(req.url);---->127.0.0.1?name=nice&age=18

----------------------------------------
const url=require('url');
if(req.url=='/favicon.ico'){
? ?var userinfo=url.parse(req.url,true).query;
? ?console.log(`姓名:${getValue.name}---年齡:${getValue.age}`);
}
------------------------------------------------------
const http=require('http');
const url=require('url');
http.createServer((req,res)=>{
? ? ? ?console.log(req.url);
? ? ? ?res.writeHead(200,{"Content-type":"text/html;charset='utf-8'"}); //解決亂碼

? ? ? ?res.write("<head> <meta charset='UTF-8'></head>"); ?//解決亂碼


? ? ? ?if(req.url!=='/favicon.ico'){
? ? ? ? ? ?var userinfo=url.parse(req.url,true).query;
? ? ? ? ? ?console.log(`姓名:${userinfo.name}---年齡:${userinfo.age}`);
? ? ? ?}

? ? ? ?res.end("中華民族偉大復(fù)興");
? ?}
).listen(3001);

console.log("server running at localhost:3001");

2023.4.4的課程講義的評論 (共 條)

分享到微博請遵守國家法律
宁国市| 溆浦县| 沐川县| 平阴县| 陆川县| 西盟| 渝北区| 昌乐县| 承德市| 探索| 鲁甸县| 兴义市| 榆树市| 安宁市| 新田县| 万源市| 新河县| 蒲江县| 连州市| 满城县| 木兰县| 武强县| 吉水县| 新余市| 青阳县| 安阳县| 维西| 新巴尔虎左旗| 当雄县| 大冶市| 青阳县| 西乡县| 桃江县| 嘉义县| 蓬莱市| 台山市| 凤翔县| 张家港市| 侯马市| 昆明市| 鄯善县|