Ajax-day2(圖書管理)-渲染列表

本篇筆記素材來自“黑馬程序員”

渲染列表

  • 圖書管理
  • 一、獲取數據
  • 二、渲染數據
  • 完整代碼


圖書管理

  1. Bootstrap 框架
  2. 渲染列表(查)
  3. 新增圖書(增)
  4. 刪除圖書(刪)
  5. 編輯圖書(改)

自己的圖書數據:給自己起個名字,并告訴服務器,
默認會有三本書,基于這三本書做數據的增刪改查。

文件夾目錄:
在這里插入圖片描述
index.html

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>案例-圖書管理</title><!-- 字體圖標 --><link rel="stylesheet" href="https://at.alicdn.com/t/c/font_3736758_vxpb728fcyh.css"><!-- 引入bootstrap.css --><link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet"><!-- 核心樣式 --><link rel="stylesheet" href="./css/index.css">
</head><body><!-- 主體區域 --><div class="container"><!-- 頭部標題和添加按鈕 --><div class="top"><h3>圖書管理</h3><button type="button" class="btn btn-primary plus-btn" data-bs-toggle="modal" data-bs-target=".add-modal"> + 添加</button></div><!-- 數據列表 --><table class="table"><thead class="table-light"><tr><th style="width: 150px;">序號</th><th>書名</th><th>作者</th><th>出版社</th><th style="width: 180px;">操作</th></tr></thead><tbody class="list"><tr><td>1</td><td>JavaScript程序設計</td><td>馬特·弗里斯比</td><td>人民郵電出版社</td><td><span class="del">刪除</span><span class="edit">編輯</span></td></tr></tbody></table></div><!-- 新增-彈出框 --><div class="modal fade add-modal"><!-- 中間白色區域 --><div class="modal-dialog"><div class="modal-content"><div class="modal-header top"><span>添加圖書</span><button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal"></button></div><div class="modal-body form-wrap"><!-- 新增表單 --><form class="add-form"><div class="mb-3"><label for="bookname" class="form-label">書名</label><input type="text" class="form-control bookname" placeholder="請輸入書籍名稱" name="bookname"></div><div class="mb-3"><label for="author" class="form-label">作者</label><input type="text" class="form-control author" placeholder="請輸入作者名稱" name="author"></div><div class="mb-3"><label for="publisher" class="form-label">出版社</label><input type="text" class="form-control publisher" placeholder="請輸入出版社名稱" name="publisher"></div></form></div><div class="modal-footer btn-group"><button type="button" class="btn btn-primary" data-bs-dismiss="modal"> 取消 </button><button type="button" class="btn btn-primary add-btn"> 保存 </button></div></div></div></div><!-- 編輯-彈出框 --><div class="modal fade edit-modal"><!-- 中間白色區域 --><div class="modal-dialog"><div class="modal-content"><div class="modal-header top"><span>編輯圖書</span><button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal"></button></div><div class="modal-body form-wrap"><!-- 編輯表單 --><form class="edit-form"><input type="hidden" class="id" name="id"><div class="mb-3"><label for="bookname" class="form-label">書名</label><input type="text" class="form-control bookname" placeholder="請輸入書籍名稱" name="bookname"></div><div class="mb-3"><label for="author" class="form-label">作者</label><input type="text" class="form-control author" placeholder="請輸入作者名稱" name="author"></div><div class="mb-3"><label for="publisher" class="form-label">出版社</label><input type="text" class="form-control publisher" placeholder="請輸入出版社名稱" name="publisher"></div></form></div><div class="modal-footer btn-group"><button type="button" class="btn btn-primary" data-bs-dismiss="modal"> 取消 </button><button type="button" class="btn btn-primary edit-btn"> 修改 </button></div></div></div></div><script src="https://cdn.bootcdn.net/ajax/libs/axios/1.2.0/axios.min.js"></script><script src="./lib/form-serialize.js"></script><script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/js/bootstrap.min.js"></script><!-- 核心邏輯 --><script src="./js/index.js"></script>
</body></html>

index.css

/* 公共*/
html,
body {width: 100%;height: 100%;
}.container {width: 1340px;margin: 0 auto;padding-top: 60px;box-sizing: border-box;
}/* alert提示框 */
.toast {position: fixed;top: 20px;left: 50%;transform: translateX(-50%);
}.toast .toast-body {padding: 0 !important;
}.toast .alert-success {margin-bottom: 0 !important;
}/* 頭部導航 */
.container .top {display: flex;justify-content: space-between;
}.container .top h3 {font-weight: 900;
}.container .top .plus-btn {background-color: #539ACB !important;color: #fff;border: none;
}/* 表格部分 */
.table {margin-top: 20px;text-align: center;font-size: 14px;
}.table-light th {background-color: #939CA7 !important;color: #ffffff;font-family: PingFangSC-Medium;font-size: 16px;text-align: center;font-weight: 500;border-right: 1px solid lightgray;
}.table-light th:last-of-type {border-right: none;
}/* 表格內容 */
.table tbody td {color: #696F77;
}.table .del {color: #E5964C;margin-right: 30px;
}.table .edit {color: #539ACB;
}.table tbody tr {height: 30px;line-height: 30px;
}.table tbody tr td:last-of-type span {cursor: pointer;
}/* 彈出層 */
.modal .top {display: flex;justify-content: center;background-color: #F0F3F7;padding: 15px 0;width: 100%;position: relative;color: #1E2023;
}/* 右上角-關閉按鈕 */
.modal .btn-close {font-size: 12px;position: absolute;top: 50%;transform: translateY(-50%);right: 23px;/* 覆蓋bootstrap樣式 */margin: 0;padding: 0;
}/* 表單容器 */
.form-wrap {box-sizing: border-box;background-color: white;padding: 40px;
}.form-wrap .form-label {color: #696F77;
}/* 修改輸入框默認占位文字webkit內核, firefox18-, firfox19+, 其他*/
.form-wrap input::-webkit-input-placeholder {color: #BFBFBF !important;font-size: 14px;
}/* 底部按鈕組 */
.modal-footer{border-top: 0;
}
.btn-group {text-align: center;width: 100%;
}/* 修改bs的按鈕彈性布局-改成自己設置大小 */
.btn-group,
.btn-group-vertical {display: block;
}.btn-group button {width: 120px
}.btn-group button:first-of-type {border: 1px solid #E3E3E3;background-color: #fff;color: black;margin-right: 60px;
}.btn-group button:last-of-type {background-color: #539ACB;
}.alert-success {border-color: transparent;
}.toast {border: none;
}

form-serialize.js

// get successful control from form and assemble into object
// http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2// types which indicate a submit action and are not successful controls
// these will be ignored
var k_r_submitter = /^(?:submit|button|image|reset|file)$/i;// node names which could be successful controls
var k_r_success_contrls = /^(?:input|select|textarea|keygen)/i;// Matches bracket notation.
var brackets = /(\[[^\[\]]*\])/g;// serializes form fields
// @param form MUST be an HTMLForm element
// @param options is an optional argument to configure the serialization. Default output
// with no options specified is a url encoded string
//    - hash: [true | false] Configure the output type. If true, the output will
//    be a js object.
//    - serializer: [function] Optional serializer function to override the default one.
//    The function takes 3 arguments (result, key, value) and should return new result
//    hash and url encoded str serializers are provided with this module
//    - disabled: [true | false]. If true serialize disabled fields.
//    - empty: [true | false]. If true serialize empty fields
function serialize(form, options) {if (typeof options != 'object') {options = { hash: !!options };}else if (options.hash === undefined) {options.hash = true;}var result = (options.hash) ? {} : '';var serializer = options.serializer || ((options.hash) ? hash_serializer : str_serialize);var elements = form && form.elements ? form.elements : [];//Object store each radio and set if it's empty or notvar radio_store = Object.create(null);for (var i=0 ; i<elements.length ; ++i) {var element = elements[i];// ingore disabled fieldsif ((!options.disabled && element.disabled) || !element.name) {continue;}// ignore anyhting that is not considered a success fieldif (!k_r_success_contrls.test(element.nodeName) ||k_r_submitter.test(element.type)) {continue;}var key = element.name;var val = element.value;// we can't just use element.value for checkboxes cause some browsers lie to us// they say "on" for value when the box isn't checkedif ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) {val = undefined;}// If we want empty elementsif (options.empty) {// for checkboxif (element.type === 'checkbox' && !element.checked) {val = '';}// for radioif (element.type === 'radio') {if (!radio_store[element.name] && !element.checked) {radio_store[element.name] = false;}else if (element.checked) {radio_store[element.name] = true;}}// if options empty is true, continue only if its radioif (val == undefined && element.type == 'radio') {continue;}}else {// value-less fields are ignored unless options.empty is trueif (!val) {continue;}}// multi select boxesif (element.type === 'select-multiple') {val = [];var selectOptions = element.options;var isSelectedOptions = false;for (var j=0 ; j<selectOptions.length ; ++j) {var option = selectOptions[j];var allowedEmpty = options.empty && !option.value;var hasValue = (option.value || allowedEmpty);if (option.selected && hasValue) {isSelectedOptions = true;// If using a hash serializer be sure to add the// correct notation for an array in the multi-select// context. Here the name attribute on the select element// might be missing the trailing bracket pair. Both names// "foo" and "foo[]" should be arrays.if (options.hash && key.slice(key.length - 2) !== '[]') {result = serializer(result, key + '[]', option.value);}else {result = serializer(result, key, option.value);}}}// Serialize if no selected options and options.empty is trueif (!isSelectedOptions && options.empty) {result = serializer(result, key, '');}continue;}result = serializer(result, key, val);}// Check for all empty radio buttons and serialize them with key=""if (options.empty) {for (var key in radio_store) {if (!radio_store[key]) {result = serializer(result, key, '');}}}return result;
}function parse_keys(string) {var keys = [];var prefix = /^([^\[\]]*)/;var children = new RegExp(brackets);var match = prefix.exec(string);if (match[1]) {keys.push(match[1]);}while ((match = children.exec(string)) !== null) {keys.push(match[1]);}return keys;
}function hash_assign(result, keys, value) {if (keys.length === 0) {result = value;return result;}var key = keys.shift();var between = key.match(/^\[(.+?)\]$/);if (key === '[]') {result = result || [];if (Array.isArray(result)) {result.push(hash_assign(null, keys, value));}else {// This might be the result of bad name attributes like "[][foo]",// in this case the original `result` object will already be// assigned to an object literal. Rather than coerce the object to// an array, or cause an exception the attribute "_values" is// assigned as an array.result._values = result._values || [];result._values.push(hash_assign(null, keys, value));}return result;}// Key is an attribute name and can be assigned directly.if (!between) {result[key] = hash_assign(result[key], keys, value);}else {var string = between[1];// +var converts the variable into a number// better than parseInt because it doesn't truncate away trailing// letters and actually fails if whole thing is not a numbervar index = +string;// If the characters between the brackets is not a number it is an// attribute name and can be assigned directly.if (isNaN(index)) {result = result || {};result[string] = hash_assign(result[string], keys, value);}else {result = result || [];result[index] = hash_assign(result[index], keys, value);}}return result;
}// Object/hash encoding serializer.
function hash_serializer(result, key, value) {var matches = key.match(brackets);// Has brackets? Use the recursive assignment function to walk the keys,// construct any missing objects in the result tree and make the assignment// at the end of the chain.if (matches) {var keys = parse_keys(key);hash_assign(result, keys, value);}else {// Non bracket notation can make assignments directly.var existing = result[key];// If the value has been assigned already (for instance when a radio and// a checkbox have the same name attribute) convert the previous value// into an array before pushing into it.//// NOTE: If this requirement were removed all hash creation and// assignment could go through `hash_assign`.if (existing) {if (!Array.isArray(existing)) {result[key] = [ existing ];}result[key].push(value);}else {result[key] = value;}}return result;
}// urlform encoding serializer
function str_serialize(result, key, value) {// encode newlines as \r\n cause the html spec says sovalue = value.replace(/(\r)?\n/g, '\r\n');value = encodeURIComponent(value);// spaces should be '+' rather than '%20'.value = value.replace(/%20/g, '+');return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
}

index.js
(我們要寫的)

打開index.html,會有這樣的效果:

在這里插入圖片描述
而且點擊”添加“按鈕,會有彈框。

在這里插入圖片描述


一、獲取數據

1.首先,封裝函數,功能:獲取并渲染圖書列表。
而且每打開/刷新一次網頁,就獲取并渲染列表一次,即調用函數。

// 封裝-獲取并渲染圖書列表函數
function getBooksList() {// 函數體
}// 網頁加載運行,獲取并渲染列表一次
getBooksList()

2.獲取數據(axios)

下圖是接口文檔截圖。

在這里插入圖片描述

在這里插入圖片描述

// 封裝-獲取并渲染圖書列表函數
function getBooksList() {// 1.1 獲取數據axios({url:'https://hmajax.itheima.net/api/books',   // 接口文檔有地址,最上面的框框params:{creator:'大魚'    // 接口文檔的“請求參數”,參數名 creator}}).then(result => {console.log(result)})
}// 網頁加載運行,獲取并渲染列表一次
getBooksList()

我們看一下控制臺打印結果:
在這里插入圖片描述

我們只想得到這個數組。

result.data.data
// 封裝-獲取并渲染圖書列表函數
function getBooksList() {// 1.1 獲取數據axios({url:'https://hmajax.itheima.net/api/books',   // 接口文檔有地址,最上面的框框params:{creator:'大魚'    // 接口文檔的“請求參數”,參數名 creator}}).then(result => {console.log(result)const bookList = result.data.dataconsole.log(bookList)})
}// 網頁加載運行,獲取并渲染列表一次
getBooksList()

在這里插入圖片描述

3.給自己起一個名字。
(一個圖書管理系統嘛,經過每個用戶編輯后的圖書列表都不一樣,但是不能影響別人的圖書列表)

const creator = '大魚'
// 封裝-獲取并渲染圖書列表函數
function getBooksList() {// 1.1 獲取數據axios({url:'https://hmajax.itheima.net/api/books',   // 接口文檔有地址,最上面的框框params:{// creator: creator(參數名和參數值相同,簡寫)creator   // 接口文檔的“請求參數”,參數名 creator}}).then(result => {console.log(result)const bookList = result.data.dataconsole.log(bookList)})
}// 網頁加載運行,獲取并渲染列表一次
getBooksList()

二、渲染數據

4.渲染數據

每一行圖書對應的是 <tr></tr>
在這里插入圖片描述

在這里插入圖片描述

然后復制。

// 1.2 渲染數據const htmlStr = bookList.map(item => {return `<tr><td>1</td><td>JavaScript程序設計</td><td>馬特·弗里斯比</td><td>人民郵電出版社</td><td><span class="del">刪除</span><span class="edit">編輯</span></td></tr>`})console.log(htmlStr)
})

在這里插入圖片描述

轉換成字符串,并渲染到頁面:

// 1.2 渲染數據const htmlStr = bookList.map(item => {return `<tr><td>1</td><td>JavaScript程序設計</td><td>馬特·弗里斯比</td><td>人民郵電出版社</td><td><span class="del">刪除</span><span class="edit">編輯</span></td></tr>`}).join('')console.log(htmlStr)document.querySelector('.list').innerHTML = htmlStr
})

在這里插入圖片描述

修改內容:

在這里插入圖片描述

        // 1.2 渲染數據
const htmlStr = bookList.map((item,index) => {return `<tr><td>${index + 1}</td><td>${item.bookList}</td><td>${item.author}</td><td>${item.publisher}</td><td><span class="del">刪除</span><span class="edit">編輯</span></td></tr>`
}).join('')
console.log(htmlStr)
document.querySelector('.list').innerHTML = htmlStr
})

完整代碼

const creator = '大魚'
// 封裝-獲取并渲染圖書列表函數
function getBooksList() {// 1.1 獲取數據axios({url:'https://hmajax.itheima.net/api/books',   // 接口文檔有地址,最上面的框框params:{// creator: creator(參數名和參數值相同,簡寫)creator   // 接口文檔的“請求參數”,參數名 creator}}).then(result => {console.log(result)const bookList = result.data.dataconsole.log(bookList)// 1.2 渲染數據const htmlStr = bookList.map((item,index) => {return `<tr><td>${index + 1}</td><td>${item.bookList}</td><td>${item.author}</td><td>${item.publisher}</td><td><span class="del">刪除</span><span class="edit">編輯</span></td></tr>`}).join('')console.log(htmlStr)document.querySelector('.list').innerHTML = htmlStr})
}// 網頁加載運行,獲取并渲染列表一次
getBooksList()

在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/922326.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/922326.shtml
英文地址,請注明出處:http://en.pswp.cn/news/922326.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

MOS管的電路

MOS管的三極都會存在以下三個電容&#xff0c;分別是&#xff1a;Cgs,Cgd,Cds 輸入電容CissCgsCgd 輸出電容CossCgdCds 反向傳輸電容CrssCgd&#xff0c;也叫米勒電容 然而&#xff0c;這三個等效電容是構成串并聯組合關系&#xff0c;他們并不是獨立的&#xff0c;而是相互…

STM32_05_時鐘樹

時鐘 d用來輸入數據&#xff0c;CLK就是我們的時鐘&#xff0c;CPU1s中72000000HZ個時鐘周期STM32的時鐘樹鎖相環HSE時鐘源HSI時鐘源LSE時鐘源LSI時鐘源SystemInit函數SetSysClock函數SetSysClockTo72函數SystemInit()后時鐘頻率大小總結RCC標準庫函數定義變量a&…

C語言---判斷語句

文章目錄1. if 語句2. if...else 語句3. if...else if...else 語句4. switch 語句5. 三元運算符 ( ? : )總結與對比如何選擇C語言中的判斷語句用于根據給定的條件來決定執行哪一段代碼。其核心是條件為真&#xff08;必須&#xff09;則執行一段代碼&#xff0c;條件為假&…

[硬件電路-212]:電流的本質確實是電子的移動

1. 微觀機制&#xff1a;電子的定向漂移與熱運動定向漂移&#xff08;Drift Motion&#xff09;&#xff1a;在導體&#xff08;如金屬&#xff09;中&#xff0c;自由電子&#xff08;價電子&#xff09;受電場驅動&#xff0c;從負端向正端定向移動&#xff0c;形成宏觀電流。…

雙RFSOC47DR-16通道5GSPS ADC采集模塊

16通道5GSPS ADC采集板卡組成如圖1所示。該板卡的輸入接口為SMA單端輸入&#xff0c;ADC采集和處理采用Xilinx公司的XCZU47DR-2FFVE1156I芯片。板卡需配備4路QSFP28光口輸出&#xff0c;并需要集成網口、DDR4、SD卡、USB調試口。兩塊RF-Soc需確保連接通信功能。板卡的16通道需實…

pytest -- 中文文檔

前言 零基礎1小時快速入門pytest自動化測試教程&#xff0c;全套項目框架實戰pytest配置文件可以改變pytest的運行方式&#xff0c;它是一個固定的文件pytest.ini文件&#xff0c;讀取配置信息&#xff0c;按指定的方式去運行 非test文件 pytest里面有些文件是非test文件 pyt…

硬件開發2-ARM裸機開發3-IMX6ULL - 引入中斷

一、鋪墊引入中斷 → 按鍵1、概要&#xff1a;實現按鍵控制發光二極管和蜂鳴器輸入類型的外設&#xff1a;按鍵&#xff08;key&#xff09;2、參考手冊內容完成配置過程&#xff08;1&#xff09;key 按鍵原理圖&#xff08;2&#xff09;core 內核中命名 -- UART1 CTS&#x…

Ansible的 Playbook 模式詳解

目錄一、Playbook模式1.1 Playbook 的優勢1.2 Playbook 的組成1.3 安裝 httpd 服務案例1.4 Playbook 命令及常用參數1.5 Playbook 的語法 —— 權限相關1. remote_user2. become3. become_method1.6 Playbook 的通知與觸發機制1. notify2. handlers3. 使用示例4. 使用場景1.6 P…

猿輔導Java后臺開發面試題及參考答案

int 與 Integer 的區別是什么&#xff1f;若創建數量龐大的數字時使用 Integer&#xff0c;會對重復數字創建新對象嗎&#xff1f;int 是 Java 中的基本數據類型&#xff0c;直接存儲數值&#xff0c;占用 4 個字節&#xff0c;默認值為 0&#xff0c;不需要通過 new 關鍵字創建…

代碼隨想錄學習摘抄day9(回溯1-11)

一個樸實無華的目錄定義&#xff1a;回溯法也可以叫做回溯搜索法&#xff0c;它是一種搜索的方式。應用場景&#xff1a;回溯法解決的問題都可以抽象為樹形結構代碼模板題型第77題. 組合思路&#xff1a;每次從集合中選取元素&#xff0c;可選擇的范圍隨著選擇的進行而收縮&…

Altium Designer(AD24)打開工程文件的幾種方法

??《專欄目錄》 目錄 1,概述 2,源文件 2,菜單欄 4,工具欄 5,注意事項 1,概述 本文介紹幾種打開工程文件的方法。 2,源文件 找到工程的源文件存儲路徑,找到.PrjPcb的源工程文件,雙擊打開。 2,菜單欄 第1步:執行File→Open, 第2步:找到工程文件的存儲路徑,并選中…

Linux嵌入式自學筆記(基于野火EBF6ULL):2.點燈與ubuntu安裝

一、點燈登錄root&#xff1a;賬號&#xff1a;root ; 密碼&#xff1a;root點燈命令&#xff1a;echo 0 > /sys/class/leds/red/brightness #關閉red燈 echo 0 > /sys/class/leds/blue/brightness #關閉blue燈 echo 0 > /sys/class/leds/green/brightness …

【Java實戰?】Java實戰:MyBatis-Plus 開啟MySQL數據庫高效操作之旅

目錄 一、MyBatis-Plus 環境集成 1.1 項目依賴引入 1.2 數據庫配置 1.3 代碼生成器使用 二、核心 CRUD 操作實現 2.1 基礎查詢 2.2 數據新增與修改 2.3 復雜查詢場景 三、性能優化與高級特性 3.1 緩存配置 3.2 樂觀鎖實現 3.3 字段自動填充 四、實戰案例:用戶管理模塊開發 4.1…

開學季干貨——知識梳理與經驗分享

技術文章大綱&#xff1a;開學季干貨——知識梳理與經驗分享目標受眾分析明確文章面向的學生群體&#xff08;如大學生、高中生&#xff09; 分析不同群體的核心需求&#xff08;課程準備、時間管理、工具使用&#xff09; 結合技術場景&#xff08;如數字筆記、在線協作&#…

Linux《線程(上)》

通過之前的學習我們已經了解了操作系統當中的基本的概念包括進程、基礎IO、磁盤文件存儲等&#xff0c;但是到目前為止我們還未了解到線程相關的概念&#xff0c;這就使得當前我們對操作系統的認知還不是完整的&#xff0c;現在我們是還是無法理解一個進程當中是如何同時的執行…

為什么知識復用時缺乏場景化指導影響實用性

知識復用時因缺乏場景化指導而嚴重影響實用性&#xff0c;其根本原因在于知識的價值本質上根植于其應用情境。脫離了場景的“純知識”往往是抽象、片面且難以行動的。這導致了認知鴻溝的產生、隱性知識的流失、決策風險的增加、以及學習遷移效率的低下。當使用者面對一份缺乏“…

擁抱直覺與創造力:走進VibeCoding的新世界

引言 在傳統觀念里&#xff0c;編程是一項高度理性、邏輯嚴密的活動&#xff0c;開發者需要像建筑師一樣&#xff0c;用代碼一行行地精確構建數字世界。然而&#xff0c;隨著人工智能技術的飛速發展&#xff0c;一種全新的編程理念和體驗正在興起——它就是 VibeCoding&#xf…

HTTP的Web服務測試在Python中的實現

在Web開發領域&#xff0c;對HTTP Web服務進行測試是確保服務穩定性和可靠性的關鍵步驟。Python作為一種功能強大的編程語言&#xff0c;提供了多種工具和庫來簡化這一過程。本文將介紹如何在Python中實現HTTP的Web服務測試。首先&#xff0c;Python的requests庫是測試HTTP Web…

Android Studio 構建項目時 Gradle 下載失敗的解決方案

一、問題原因分析根據錯誤日志&#xff1a;下載地址 https://services.gradle.org/distributions/gradle-8.1-bin.zip 連接超時&#xff08;10秒&#xff09;。可能原因&#xff1a;網絡環境限制&#xff08;如公司防火墻、地區網絡屏蔽&#xff09;。代理配置未生效或配置錯誤…

mysql 與 MongoDB 的分片

MySQL 和 MongoDB 作為不同類型數據庫的代表(關系型 vs 文檔型),其分片機制在設計理念、實現方式和適用場景上存在顯著差異。兩者的分片核心目標一致——通過水平擴展(Scale Out)解決單節點存儲容量和性能瓶頸,但因數據模型、事務支持和分布式設計理念的不同,形成了截然…