本篇笔记素材来自“黑马程序员”

渲染列表

  • 图书管理
  • 一、获取数据
  • 二、渲染数据
  • 完整代码


图书管理

  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)解决单节点存储容量和性能瓶颈,但因数据模型、事务支持和分布式设计理念的不同,形成了截然…