尊龙凯时人生就是博

jsÔõÑù´ÓurlÖлñÈ¡²ÎÊý

javascript ÌṩÁËÁ½ÖÖ»ñÈ¡ url ²ÎÊýµÄÒªÁ죺ʹÓà window.location.search »ñÈ¡ÅÌÎÊ×Ö·û´®¡£Ê¹Óà url ¹¤¾ßµÄ searchparams ÊôÐÔ¡£×¢ÖØ£º»ñÈ¡µ½µÄ²ÎÊýÖµ¶¼ÊÇ×Ö·û´®ÀàÐÍ £¬ÐèҪƾ֤ÐèÒª¾ÙÐÐÀàÐÍת»»¡£

ÔõÑùÔÚ JavaScript ÖÐ´Ó URL ÖлñÈ¡²ÎÊý

JavaScript ÌṩÁ˶àÖÖÒªÁì´Ó URL ÖлñÈ¡²ÎÊý £¬ÒÔÏÂÊÇÁ½ÖÖ³£¼ûÒªÁ죺

1. ʹÓà window.location.search

window.location.search ÊôÐÔ·µ»Ø URL ÅÌÎÊ×Ö·û´®µÄ²¿·Ö £¬ÆäÖаüÀ¨ URL ²ÎÊý¡£ÅÌÎÊ×Ö·û´®ÒÔÎʺŠ(?) ¿ªÍ· £¬ºóÃæËæ×ŲÎÊýÃûºÍÖµ¶Ô¡£

Óï·¨£º

const searchParams = window.location.search;

µÇ¼ºó¸´ÖÆ

Ó÷¨£º

// »ñÈ¡ÅÌÎÊ×Ö·û´®
const searchParams = window.location.search;

// ÌáÈ¡²ÎÊý
const params = new URLSearchParams(searchParams);

// »ñÈ¡Ìض¨²ÎÊýµÄÖµ
const value = params.get("param_name");

µÇ¼ºó¸´ÖÆ

2. ʹÓà URL ¹¤¾ß

URL ¹¤ÏêϸÏÖÒ»¸ö URL £¬ËüÌṩÁË searchParams ÊôÐÔ £¬ËüÊÇÒ»¸ö°üÀ¨ URL ²ÎÊýµÄ¹¤¾ß¡£

Óï·¨£º

const url = new URL("https://example.com?param1=value1&param2=value2");

µÇ¼ºó¸´ÖÆ

Ó÷¨£º

// »ñÈ¡ URL ¹¤¾ß
const url = new URL("https://example.com?param1=value1&param2=value2");

// »ñÈ¡²ÎÊý¹¤¾ß
const params = url.searchParams;

// »ñÈ¡Ìض¨²ÎÊýµÄÖµ
const value = params.get("param_name");

µÇ¼ºó¸´ÖÆ

×¢ÖØ£º

ÒÔÉÏÒªÁ춼»á·µ»Ø²ÎÊýµÄÖµ×÷Ϊ×Ö·û´®¡£ÈôÊÇÄúÐèÒª½«Öµ×ª»»ÎªÁíÒ»ÖÖÀàÐÍ£¨ÀýÈçÊý×Ö£© £¬ÇëʹÓÃÊʵ±µÄÀàÐÍת»»º¯Êý¡£

ijЩÌØÊâ×Ö·û£¨ÀýÈç¿Õ¸ñºÍÌØÊâ·ûºÅ£©ÔÚ URL ÖÐÐèÒª¾ÙÐбàÂë £¬ÒÔ×èÖ¹±¬·¢¹ýʧ¡£

ÒÔÉϾÍÊÇjsÔõÑù´ÓurlÖлñÈ¡²ÎÊýµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ