li { position: relative; } .top-nav > li > a, .top-nav > li > span, .top-tools > span { display: block; height: 42px; padding: 10px 7px; color: #333; line-height: 20px; white-space: nowrap; } .top-nav .more-trigger::after, .top-tools .drop-label::after { margin-left: 3px; color: #888; content: "??"; } .dropdown-menu { position: absolute; z-index: 30; top: 40px; left: 0; display: none; min-width: 128px; padding: 7px 0; border: 1px solid rgba(0,0,0,.14); box-shadow: 0 6px 12px rgba(0,0,0,.16); background: #fff; } .dropdown:hover > .dropdown-menu, .dropdown:focus-within > .dropdown-menu { display: block; } .dropdown-menu.counties { width: 170px; } .dropdown-menu.counties li { float: left; width: 50%; } .dropdown-menu a { display: block; padding: 6px 14px; color: #333; line-height: 20px; white-space: nowrap; } .top-tools > span { color: #666; } .top-tools .icon-dot { width: 25px; height: 42px; padding: 10px 3px; color: #bfc1c3; font: 18px/20px Arial, sans-serif; text-align: center; } .hotline-tool { position: relative; width: 25px; height: 42px; } .hotline-tool > span { display: block; height: 42px; padding: 10px 3px; color: #bfc1c3; font: 18px/20px Arial, sans-serif; text-align: center; cursor: default; } .hotline-menu { width: 220px; color: #2b6094; font-size: 16px; line-height: 30px; text-align: center; } #nav { height: 50px; background: transparent; } .nav-inner { height: 50px; } .navbar-header { display: flex; height: 50px; align-items: center; } .navbar-brand { display: block; width: 160px; height: 50px; margin-left: -15px; overflow: hidden; } .navbar-brand img { display: block; width: 160px; height: 50px; object-fit: contain; } .add { width: 570px; height: 50px; margin-left: 12px; overflow: hidden; color: #999; font-family: "瀹?浣?", serif; line-height: 50px; white-space: nowrap; } .add a { margin: 0 8px; color: #666; } .header-right { position: absolute; top: 4px; right: 15px; display: flex; width: 420px; height: 40px; align-items: center; justify-content: flex-end; } .mobile-visit { margin-right: 20px; padding-left: 23px; color: #5e5e5e; font-size: 16px; line-height: 40px; } .mobile-visit::before { margin-right: 5px; color: #aaa; content: "??; } .search-shell { display: flex; width: 287px; height: 40px; } .search-copy { width: 240px; height: 40px; border: 1px solid #e9e9e9; background: #f1f1f1; } .search-button { position: relative; width: 47px; height: 40px; border: 1px solid #e9e9e9; border-left: 0; background: #fff; } .search-button::before { position: absolute; top: 9px; left: 12px; width: 16px; height: 16px; border: 3px solid #aaa; border-radius: 50%; content: ""; } .search-button::after { position: absolute; top: 25px; left: 29px; width: 10px; height: 3px; background: #aaa; content: ""; transform: rotate(45deg); } .mobile-menu { display: none; } #xl-headline { margin-top: 25px; } #xl-headline .layout { height: 151px; padding-top: 30px; padding-bottom: 8px; border-bottom: 1px solid #e8e8e8; } .article-title { height: 42px; overflow: hidden; color: #252525; font-size: 36px; font-weight: 700; line-height: 42px; overflow-wrap: anywhere; } .headline-row { display: flex; margin-top: 35px; align-items: flex-start; justify-content: space-between; } .article-meta { margin-top: 15px; color: #888; font: 14px/18px "瀹?浣?", serif; } .article-meta a { color: #888; } .article-tools { display: flex; height: 35px; align-items: center; gap: 15px; } .article-tools .circle { display: inline-flex; width: 35px; height: 35px; border-radius: 50%; color: #fff; background: #d3d3d3; font: 14px/35px Arial, sans-serif; align-items: center; justify-content: center; } .article-tools .divider { width: 1px; height: 25px; margin-right: 0; background: #e5e5e5; } .content-grid { display: grid; width: 1200px; margin: 0 auto; grid-template-columns: 800px 400px; align-items: start; } .main { min-width: 0; margin: 40px 0 10px; padding: 35px 15px 0; } .sidebar { min-width: 0; margin-top: 40px; padding: 35px 15px 0; } .news-con { width: 770px; color: #111; overflow-wrap: anywhere; } .news-con > p, .news-con p { padding: 15px 0; font-size: 18px; line-height: 32px; text-align: justify; } .news-con img { display: block; width: auto; max-width: 100%; height: auto; margin: 15px auto; } .news-con strong { font-weight: 700; } .mobile-promo { margin-top: 15px; color: #619ccc; font: 14px/28px "瀹?浣?", serif; } .mobile-promo span { display: block; } .editor { display: flex; min-height: 105px; margin-top: 50px; padding: 2px 0; border-top: 1px solid #f4f4f4; border-bottom: 1px solid #f4f4f4; align-items: center; justify-content: space-between; } .share-appearance { display: flex; align-items: center; gap: 30px; } .share-appearance span { display: inline-flex; width: 35px; height: 35px; border-radius: 50%; color: #fff; background: #d4d4d4; font-size: 16px; align-items: center; justify-content: center; } .editor-text { margin-right: 33px; color: #999; font: 14px/22px "瀹?浣?", serif; text-align: left; } .content-block { margin: 30px 0 10px; } .block-title { height: 53px; border-bottom: 3px solid #dbdbdb; color: #053a67; font-size: 26px; font-weight: 400; line-height: 50px; } .related-list li { display: flex; height: 50px; border-bottom: 1px solid #f5f5f5; font-size: 18px; line-height: 50px; justify-content: space-between; gap: 12px; } .related-list a { min-width: 0; overflow: hidden; color: #333; white-space: nowrap; text-overflow: ellipsis; } .related-list time { color: #999; font-size: 14px; white-space: nowrap; } .recommend-list li { padding: 25px 0 20px; border-bottom: 1px solid #f3f3f3; } .recommend-list h3 { height: 34px; margin-bottom: 12px; overflow: hidden; color: #333; font-size: 20px; font-weight: 400; line-height: 34px; white-space: nowrap; text-overflow: ellipsis; } .recommend-list p { color: #555; font-size: 15px; line-height: 26px; } .recommend-tail { margin-top: 8px; color: #999; font-size: 13px; } .side-inner { width: 300px; margin-left: auto; overflow: hidden; } .side-block { margin-bottom: 35px; } .side-title { color: #053a67; font-size: 22px; font-weight: 400; line-height: 30px; } .side-photo { margin-top: 25px; } .side-photo img { display: block; width: 300px; height: 188px; object-fit: cover; } .side-photo p { height: 25px; margin-top: 5px; overflow: hidden; color: #333; font-size: 14px; line-height: 20px; white-space: nowrap; text-overflow: ellipsis; } .side-list { margin-top: 12px; } .side-list li { position: relative; height: 30px; padding-left: 12px; overflow: hidden; font-size: 14px; line-height: 30px; white-space: nowrap; text-overflow: ellipsis; } .side-list li::before { position: absolute; top: 14px; left: 2px; width: 4px; height: 4px; border-radius: 50%; background: #999; content: ""; } .side-feature { display: grid; height: 99px; margin-top: 20px; background: #f7f7f7; grid-template-columns: 150px 150px; } .side-feature img { width: 150px; height: 99px; object-fit: cover; } .side-feature p { display: flex; padding: 0 12px; font-size: 15px; line-height: 24px; align-items: center; } #bottom-nav { margin-top: 70px; border-top: 1px solid #4a4a4a; color: #ddd; background: #575757; font: 12px/24px "瀹?浣?", serif; } #bottom-nav a { color: #ddd; } #bottom-nav .layout { display: grid; padding-top: 22px; padding-bottom: 22px; grid-template-columns: repeat(5, 1fr); gap: 24px; } .bottom-block h2 { height: 42px; color: #eee; font: 400 20px/42px "Microsoft YaHei", sans-serif; text-align: center; } .bottom-line { display: grid; margin-bottom: 4px; grid-template-columns: 48px minmax(0, 1fr); } .bottom-line strong { color: #fff; } .bottom-line span a { display: inline-block; margin-right: 8px; } #footer { min-height: 147px; border-top: 1px solid #686868; color: #ddd; background: #575757; font: 12px/24px "瀹?浣?", serif; text-align: center; } #footer .layout { padding-top: 25px; padding-bottom: 25px; } #footer a { color: #ddd; } #footer-mobile { display: none; } @media (max-width: 767px) { .container, .layout { width: 100%; } #top { display: none; } #nav { height: 50px; background: #1066af; } .nav-inner { width: 100%; padding: 0; } .navbar-header { padding-left: 12px; justify-content: space-between; } .navbar-brand { margin-left: 0; background: #fff; } .add, .header-right { display: none; } .mobile-menu { position: relative; z-index: 50; display: block; height: 50px; } .mobile-menu summary { display: flex; width: 42px; height: 34px; margin: 8px 14px 0 0; border-radius: 4px; background: #fff; cursor: pointer; list-style: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px; } .mobile-menu summary::-webkit-details-marker { display: none; } .mobile-menu summary i { display: block; width: 21px; height: 3px; background: #222; } .mobile-links { position: absolute; z-index: 60; top: 50px; right: 0; display: grid; width: 240px; padding: 10px; box-shadow: 0 8px 18px rgba(0,0,0,.2); background: #1066af; grid-template-columns: 1fr 1fr; } .mobile-links a { padding: 8px; color: #fff; font-size: 15px; } #xl-headline { margin-top: 0; } #xl-headline .layout { height: 83px; padding-top: 15px; padding-bottom: 15px; } .article-title { height: 26px; font-size: 20px; font-weight: 400; line-height: 26px; white-space: nowrap; text-overflow: ellipsis; } .headline-row { display: block; margin-top: 10px; } .article-meta { margin-top: 0; font-size: 12px; line-height: 16px; white-space: nowrap; } .article-tools { display: none; } .content-grid { display: block; width: 100%; } .main { width: 100%; margin-top: 20px; padding: 5px 15px 0; } .news-con { width: 100%; } .news-con > p, .news-con p { padding: 5px 0; font-size: 16px; line-height: 26px; } .news-con img { width: 100%; height: auto; } .mobile-promo { margin-top: 10px; font-size: 12px; line-height: 22px; } .editor { min-height: 122px; margin-top: 20px; flex-direction: column; align-items: stretch; } .share-appearance { padding: 15px 0 10px; justify-content: space-around; } .share-appearance span { width: 35px; height: 35px; } .editor-text { margin: 12px 0 8px; font-size: 12px; line-height: 20px; } .content-block { margin-top: 20px; } .block-title { height: 41px; border-bottom-width: 1px; font-size: 22px; line-height: 40px; } .related-list li { height: 30px; font-size: 16px; line-height: 30px; } .related-list time { display: none; } .recommend-list li { padding: 16px 0; } .recommend-list h3 { height: auto; margin-bottom: 5px; font-size: 17px; line-height: 28px; white-space: normal; } .recommend-list p { display: none; } .sidebar, #bottom-nav, #footer { display: none; } #footer-mobile { display: block; width: 100%; margin-top: 20px; padding: 10px 0; border-top: 1px solid #aaa; color: #ddd; background: #575757; font-size: 14px; line-height: 30px; text-align: center; } } @media (min-width: 768px) and (max-width: 1199px) { .container { width: 970px; } .layout { width: 992px; } .top-tools { display: none; } #top { margin-bottom: 30px; } .content-grid { width: 992px; grid-template-columns: 661px 331px; } .main { margin-top: 30px; } .sidebar { margin-top: 30px; } .news-con { width: 631px; } .side-inner { width: 300px; } #xl-headline { margin-top: 20px; } #xl-headline .layout { height: 124px; padding-top: 20px; padding-bottom: 6px; } .article-title { height: 36px; font-size: 30px; line-height: 36px; } .headline-row { margin-top: 25px; } .header-right { width: 330px; } .mobile-visit { padding-left: 20px; font-size: 14px; } .search-shell { width: 227px; } .search-copy { width: 180px; } }

?ㄥ??璐?PI?ュ?g?绔?瀹???棣?娆¤????浠??ュ?d俊????澶??扮???楠?璇?

??璐?PI?ュ?g?绔???互甯??╀??ユ?惧????ㄧ???版?????★?涔???互??渚?娴?璇??ㄧ??妯℃???ュ?c???ョ???????ㄦ???伴」??腑瀹???涓?娆℃????璇锋?锛???纭???ュ?g?ㄩ??????璐归?搴﹀??璋??ㄦ?′欢锛???????妗e????璇锋?骞舵??ヨ???缁?????娉ㄦ??锛?????璐光?????芥????璐归?搴︺??璇??ㄦ????浠?渚?娴?璇?锛?骞朵?绛?浜?????璋??ㄦ?????ㄤ???涓?椤圭????

?????ㄩ????缃?绔?锛?涓?瑕??????褰????ュ??/h2>

?炬?ュ?f?讹?????娓?浣???寮????????ュ?g???????API甯??衡??杩?????瀹??????♀???????璐?璐e?绀烘?ュ?d俊???甯??哄???戒唬涓虹???瀵??ュ??濂?椁?锛???姝h????版???????″???卞?蜂??ュ?f??渚??圭淮?ゃ??????绫诲??锛?瀹规???垮?版??妗e?存?句??板???存?ヨ??ㄧ???板????

  • ?虫?ユ?惧?绉?????ュ?o???? GitHub 涓??? public-apis 椤圭???????ユ???????℃?ョ???ュ?f???︿????ㄣ?????﹁?姹?瀵??ャ?????﹀??璁镐????ㄩ??锛??跺?涓?绛?浜???璐癸?涔?涓?浠h〃???℃??缁????ㄣ??
  • ?虫?杈?涓??????″??锛?RapidAPI 绛? API 甯??轰????烘?ュ?h?????濂?椁??????圭????璐归?搴︺??璁¤垂?瑰??????????跺?????﹁?姹?缁?瀹????淇℃???濂?椁?浠ユ???¤???椤典负????
  • ???抽?璇?????绔??姹?锛?JSONPlaceholder 杩?绫绘ā?? REST API ????缁?涔???婕?绀恒??瀹?杩???娴?璇??版???涓?搴?褰?浣???瀹?涓??℃?版???锛????ユ??浣?涔????浼?????浜х郴缁??f?锋??涔?淇?瀛???
  • ?虫?炬?ュ?h???锛?Apis.guru 绛????涓昏???渚? OpenAPI 瑙??????ュ?f??杩般???垮?拌?????浠?瑕?纭?????″?板????璁よ??瑰??????$?舵??锛?涓??芥??瑙?????浠跺??????存?ヤ娇?ㄧ????璐规???°??

濡?????姹???ぉ姘????充????板?炬?版????存?ユ?ョ??瀵瑰??版????渚??圭??寮?????妗i??甯告?寸ǔ濡ャ??纭???版???ユ????ㄩ??璁稿????璋??ㄩ???跺?????ュ?ワ?涓?瑕?浠????涓??圭???涓???????璐光????绛惧?ゆ???藉?﹂?挎??浣跨?ㄣ??

璋??ㄥ????澶?濂藉??椤逛俊??/h2>

纭???????ュ?e??锛???浠???妗d腑?惧?颁互涓???瀹广??缂哄??朵腑浠讳?涓?椤癸??藉???藉??磋?姹?澶辫触??璇??ㄦ?版????

  1. ?虹??板??涓?璺??锛?纭??璇锋???寰???釜???★?浠ュ??璧?婧?璺??濡?浣??兼?ャ??澶??舵??妗d腑??绀轰??讹?????娴?璇??????姝e???????︿?????
  2. 璇锋??规?涓????帮?纭??浣跨? GET??POST 绛?????规?锛????版?惧?ㄦ?ヨ?瀛?绗︿覆??璇锋?澶磋????姹?浣?涓???涓?瑕??????ュ?e??绉扮???煎???
  3. 璁よ?瑕?姹?锛??ョ?????﹂??瑕? API Key??浠ょ????璐﹀?锋??????瀵??ュ?浠??у?跺?版????妗e??寰?锛?涓?瑕???绀轰?瀵??ュ?????繁???????
  4. ??璐硅???涓??ㄩ??锛?璁板?棰?搴﹀?ㄦ????姣?????璇锋??般??瓒?棰?澶????瑰???璁稿?????淬??寮???娴?璇???璐癸?涓?涓?瀹????崇????浜х???????涓??ㄩ????璐广??

浠?棣?娆¤?姹??扮‘璁よ?????/h2>

???ㄦ??绠?????????ュ?i?璇?杩????э?涓?瑕?涓?寮?濮?灏辨?ュ?ヤ??℃?绋??????ф?ュ?f??妗e~???板????璺???????帮???????妗h?姹??舵??娣诲??璁よ?澶淬??涓??㈡????? JavaScript 绀轰?锛????????挎??负璇ユ?ュ?f??妗f??渚?????瀹癸?

const response = await fetch(`${BASE_URL}${PATH}`);
if (!response.ok) {
  throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
console.log(data);

?ц???妫??ヤ?浠朵?锛?HTTP ?舵???????︽????????搴????︿负棰????煎????抽???娈垫???﹀??ㄣ??HTTP 200 ?????璇锋??ㄥ??璁??????锛?涓?浠h〃杩??????版???瀹?绗﹀??涓??¢??瑕?锛?杩?瑕??稿?瀛?娈靛????绫诲????绌哄?煎???存?版?堕?淬??

?ユ?ュ?i??瑕????版??璁よ?锛?灏?瀹?浠?弗?兼?惧?ㄦ??妗f??瀹???浣?缃???渚?濡?锛???妗h?姹??ヨ????帮?灏辨??绾﹀?缂??????帮?瑕?姹?浠ょ??璇锋?澶达?灏变娇?ㄦ??瀹???璇锋?澶存?煎???涓?瑕???瀵??ュ??杩????缃?椤电????绔?唬??????浜ゅ?板???浠g??浠?搴???娴?瑙??ㄨ??ㄩ???拌法????璇??讹????ョ?????℃???﹀??璁告?瑙??ㄦ?ユ?锛??ヤ???璁革????辫??繁????绔?唬涓鸿?姹?锛?浣?浠?椤婚?靛????℃?℃???

澶辫触?舵???拌薄瀹?浣?

  • 401 ?? 403锛?妫??ュ??ユ???︾己澶便??杩??????鹃??浣?缃??骞剁‘璁よ处?锋???︽??璇ユ?ュ?f??????
  • 404锛?瀵圭?ф??妗f?稿??虹??板????璺?????????峰??璇锋??规?锛?璺???奸??涓??ュ?d?绾块?藉???藉?虹?版?绫荤?????
  • 429锛???甯歌〃绀鸿Е??棰?????棰?搴﹂???躲????浣?璇锋?棰???锛??ョ????缃??堕?达?涓?瑕???杩??存?㈣处?疯??挎???¤?????
  • 杩???绌烘?版????瀛?娈靛????锛?纭?????拌???淬???版??????板?哄???ュ?g????????瑕?绋冲?杩?琛??讹?搴?澶???绌哄?煎苟???х?????????
  • ???板???ㄣ??缃?椤典??????妫??ヨ法??绛??ュ??娴?瑙??ㄦ?у?跺?版?ラ??锛?涓?瑕???瀵??ユ?撮?插?ㄥ??绔??ョ?杩????躲??

褰?璇锋??舵??姝e父????搴?瀛?娈电???棰???锛?骞朵???璐归?搴︿??ㄩ??婊¤冻椤圭???姹?锛???绠?瀹???棣?娆℃?ュ?ャ????澶?涓?绾垮??锛????ㄥ?????瀹?涓??℃?版????杈圭??娴?璇?锛?骞惰?褰??ュ?g??????棰?搴﹂???跺??????澶????瑰?锛??ユ???℃??娉?淇?璇???缁??????灏变负瓒??躲????娴????ュ?d?绾垮??澶??夸唬?规???

???村??伴?伙?璇峰?虫敞??娴锋?ユ?伴?烩??瀹㈡?风?????灞变????烘?ワ????惰?峰?????版?伴?昏?璁???

??瀹$?杈?锛?璧垫??/p>

璐d换缂?杈?锛???濠?

?稿?虫?伴??/h2>
?ㄨ????璇?/h2>