当前位置: 首页 > news >正文

【Vue】- ref获取DOM元素和购物车案例分析

文章目录

  • 知识回顾
  • 前言
  • 源码分析
    • 1. ref
    • 2. 购物车案例分析
    • 3. 购物车计算、全选
  • 拓展知识
    • 数据持久化localStorage
  • 总结


知识回顾

前言

元素上使用 ref属性关联响应式数据,获取DOM元素

步骤

● 创建 ref => const hRef = ref(null)
● 模板中建立关联 => <h1 ref="hRef">我是标题</h1>=> hRef.value

源码分析

1. ref

const inp = ref<null | HTMLInputElement>()
const img = ref<null | HTMLImageElement>()

vue

<script setup lang="ts">
import { onMounted, ref } from 'vue'const words = ref('')
const inp = ref<null | HTMLInputElement>()
const img = ref<null | HTMLImageElement>()
onMounted(() => {console.log('onMounted')inp.value?.focus()img.valueconsole.log(img.value)console.log(inp.value)
})
</script><template><div class="container" id="app"><div class="search-container"><img ref="img" src="https://" alt="" /><div class="search-box"><input ref="inp" type="text" v-model="words" id="inp" /><button>搜索一下</button></div></div></div>
</template><style>
html,
body {height: 100%;
}.search-container {position: absolute;top: 30%;left: 50%;transform: translate(-50%, -50%);text-align: center;
}.search-container .search-box {display: flex;
}.search-container img {margin-bottom: 30px;
}.search-container .search-box input {width: 512px;height: 16px;padding: 12px 16px;font-size: 16px;margin: 0;vertical-align: top;outline: 0;box-shadow: none;border-radius: 10px 0 0 10px;border: 2px solid #c4c7ce;background: #fff;color: #222;overflow: hidden;box-sizing: content-box;-webkit-tap-highlight-color: transparent;
}.search-container .search-box button {cursor: pointer;width: 112px;height: 44px;line-height: 41px;line-height: 42px;background-color: #ad2a27;border-radius: 0 10px 10px 0;font-size: 17px;box-shadow: none;font-weight: 400;border: 0;outline: 0;letter-spacing: normal;color: white;
}body {background: no-repeat center / cover;background-color: #edf0f5;
}
</style>

2. 购物车案例分析

列表渲染、购物车增加删除
css

.app-container {padding-bottom: 300px;width: 800px;margin: 0 auto;
}
@media screen and (max-width: 800px) {.app-container {width: 600px;}
}
.app-container .banner-box {border-radius: 20px;overflow: hidden;margin-bottom: 10px;
}
.app-container .banner-box img {width: 100%;
}
.app-container .nav-box {background: #ddedec;height: 60px;border-radius: 10px;padding-left: 20px;display: flex;align-items: center;
}
.app-container .nav-box .my-nav {display: inline-block;background: #5fca71;border-radius: 5px;width: 90px;height: 35px;color: white;text-align: center;line-height: 35px;margin-right: 10px;
}.breadcrumb {font-size: 16px;color: gray;
}
.table {width: 100%;text-align: left;border-radius: 2px 2px 0 0;border-collapse: separate;border-spacing: 0;
}
.th {color: rgba(0, 0, 0, 0.85);font-weight: 500;text-align: left;background: #fafafa;border-bottom: 1px solid #f0f0f0;transition: background 0.3s ease;
}
.th.num-th {flex: 1.5;
}
.th {text-align: center;
}
.th:nth-child(4),
.th:nth-child(5),
.th:nth-child(6),
.th:nth-child(7) {text-align: center;
}
.th.th-pic {flex: 1.3;
}
.th:nth-child(6) {flex: 1.3;
}.th,
.td {position: relative;padding: 16px 16px;overflow-wrap: break-word;flex: 1;
}
.pick-td {font-size: 14px;
}
.main,
.empty {border: 1px solid #f0f0f0;margin-top: 10px;
}
.tr {display: flex;cursor: pointer;border-bottom: 1px solid #ebeef5;
}
.tr.active {background-color: #f5f7fa;
}
.td {display: flex;justify-content: center;align-items: center;
}.table img {width: 100px;height: 100px;
}button {outline: 0;box-shadow: none;color: #fff;background: #d9363e;border-color: #d9363e;color: #fff;background: #d9363e;border-color: #d9363e;line-height: 1.5715;position: relative;display: inline-block;font-weight: 400;white-space: nowrap;text-align: center;background-image: none;border: 1px solid transparent;box-shadow: 0 2px 0 rgb(0 0 0 / 2%);cursor: pointer;transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;touch-action: manipulation;height: 32px;padding: 4px 15px;font-size: 14px;border-radius: 2px;
}
button.pay {background-color: #3f85ed;margin-left: 20px;
}.bottom {height: 60px;display: flex;align-items: center;justify-content: space-between;padding-right: 20px;border: 1px solid #f0f0f0;border-top: none;padding-left: 20px;
}
.right-box {display: flex;align-items: center;
}
.check-all {cursor: pointer;
}
.price {color: hotpink;font-size: 30px;font-weight: 700;
}
.price-box {display: flex;align-items: center;
}
.empty {padding: 20px;text-align: center;font-size: 30px;color: #909399;
}
.my-input-number {display: flex;
}
.my-input-number button {height: 40px;color: #333;border: 1px solid #dcdfe6;background-color: #f5f7fa;
}
.my-input-number button:disabled {cursor: not-allowed!important;
}
.my-input-number .my-input__inner {height: 40px;width: 50px;padding: 0;border: none;border-top: 1px solid #dcdfe6;border-bottom: 1px solid #dcdfe6;
}

vue

<script setup lang="ts">
import { ref } from 'vue'// 定义水果对象的类型
interface Fruit {id: numbericon: stringisChecked: booleannum: numberprice: number
}// 水果列表
const fruitList = ref<Fruit[]>([{id: 1,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/ll.png',isChecked: true,num: 2,price: 6},{id: 2,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/smt.png',isChecked: false,num: 7,price: 20},{id: 3,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/tg.png',isChecked: false,num: 3,price: 40},{id: 4,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/xg.png',isChecked: false,num: 10,price: 3},{id: 5,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/yl.png',isChecked: false,num: 20,price: 34}
])// 删除商品
const delGoods = (id: number) => {fruitList.value = fruitList.value.filter((item) => item.id !== id)
}
// 添加
const addGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num++
}
// 减少
const subGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num--
}
</script><template><div class="app-container" id="app"><!-- 顶部banner --><div class="banner-box"><img src="https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/sg_top.png" alt="" /></div><!-- 面包屑 --><div class="breadcrumb"><span>🏠</span>/<span>购物车</span></div><!-- 购物车主体 --><div v-if="fruitList.length > 0" class="main"><div class="table"><!-- 头部 --><div class="thead"><div class="tr"><div class="th">选中</div><div class="th th-pic">图片</div><div class="th">单价</div><div class="th num-th">个数</div><div class="th">小计</div><div class="th">操作</div></div></div><!-- 身体 --><div class="tbody"><divv-for="item in fruitList":key="item.id"class="tr":class="{ active: item.isChecked }"><div class="td"><input type="checkbox" v-model="item.isChecked" /></div><div class="td"><img :src="item.icon" alt="" /></div><div class="td">{{ item.price }}</div><div class="td"><div class="my-input-number"><button :disabled="item.num <= 1" class="decrease" @click="subGoods(item.id)">-</button><span class="my-input__inner">{{ item.num }}</span><button class="increase" @click="addGoods(item.id)">+</button></div></div><div class="td">{{ item.price * item.num }}</div><div class="td" @click="delGoods(item.id)"><button>删除</button></div></div></div></div><!-- 底部 --><div class="bottom"><!-- 全选 --><label class="check-all"><input type="checkbox" />全选</label><div class="right-box"><!-- 所有商品总价 --><span class="price-box">总价&nbsp;&nbsp;:&nbsp;&nbsp;¥&nbsp;<span class="price">24</span></span><!-- 结算按钮 --><button class="pay">结算( 6 )</button></div></div></div><!-- 空车 --><div v-else class="empty">🛒空空如也</div></div>
</template><style scoped>
@import './style/inputnumber.css';
@import './style/index.css';
</style>

3. 购物车计算、全选

<script setup lang="ts">
import { computed, ref } from 'vue'// 定义水果对象的类型
interface Fruit {id: numbericon: stringisChecked: booleannum: numberprice: number
}// 水果列表
const fruitList = ref<Fruit[]>([{id: 1,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/ll.png',isChecked: true,num: 2,price: 6},{id: 2,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/smt.png',isChecked: false,num: 7,price: 20},{id: 3,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/tg.png',isChecked: false,num: 3,price: 40},{id: 4,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/xg.png',isChecked: false,num: 10,price: 3},{id: 5,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/yl.png',isChecked: false,num: 20,price: 34}
])// 删除商品
const delGoods = (id: number) => {fruitList.value = fruitList.value.filter((item) => item.id !== id)
}
// 添加
const addGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num++
}
// 减少
const subGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num--
}// 全选
const checkAll = computed({get() {return fruitList.value.every((item) => item.isChecked)},set(value) {fruitList.value.forEach((item) => (item.isChecked = value))}
})// 统计选中的总数 reduce
const totalCount = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {// 选中 → 需要累加return sum + item.num} else {// 没选中 → 不需要累加return sum}}, 0)
})// 总计选中的总价 num * price
const totalPrice = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {return sum + item.num * item.price} else {return sum}}, 0)
})
</script><template><div class="app-container" id="app"><!-- 顶部banner --><div class="banner-box"><img src="https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/sg_top.png" alt="" /></div><!-- 面包屑 --><div class="breadcrumb"><span>🏠</span>/<span>购物车</span></div><!-- 购物车主体 --><div v-if="fruitList.length > 0" class="main"><div class="table"><!-- 头部 --><div class="thead"><div class="tr"><div class="th">选中</div><div class="th th-pic">图片</div><div class="th">单价</div><div class="th num-th">个数</div><div class="th">小计</div><div class="th">操作</div></div></div><!-- 身体 --><div class="tbody"><divv-for="item in fruitList":key="item.id"class="tr":class="{ active: item.isChecked }"><div class="td"><input type="checkbox" v-model="item.isChecked" /></div><div class="td"><img :src="item.icon" alt="" /></div><div class="td">{{ item.price }}</div><div class="td"><div class="my-input-number"><button :disabled="item.num <= 1" class="decrease" @click="subGoods(item.id)">-</button><span class="my-input__inner">{{ item.num }}</span><button class="increase" @click="addGoods(item.id)">+</button></div></div><div class="td">{{ item.price * item.num }}</div><div class="td" @click="delGoods(item.id)"><button>删除</button></div></div></div></div><!-- 底部 --><div class="bottom"><!-- 全选 --><label class="check-all"><input type="checkbox" v-model="checkAll" />全选</label><div class="right-box"><!-- 所有商品总价 --><span class="price-box">总价&nbsp;&nbsp;:&nbsp;&nbsp;¥&nbsp;<span class="price">{{ totalPrice }}</span></span><!-- 结算按钮 --><button class="pay">结算( {{ totalCount }} )</button></div></div></div><!-- 空车 --><div v-else class="empty">🛒空空如也</div></div>
</template><style scoped>
@import './style/inputnumber.css';
@import './style/index.css';
</style>

拓展知识

数据持久化localStorage

<script setup lang="ts">
import { computed, ref, watch } from 'vue'// 定义水果对象的类型
interface Fruit {id: numbericon: stringisChecked: booleannum: numberprice: number
}
const defaultData = [{id: 1,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/ll.png',isChecked: true,num: 2,price: 6},{id: 2,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/smt.png',isChecked: false,num: 7,price: 20},{id: 3,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/tg.png',isChecked: false,num: 3,price: 40},{id: 4,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/xg.png',isChecked: false,num: 10,price: 3},{id: 5,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/yl.png',isChecked: false,num: 20,price: 34}
]// 水果列表
let fruitList = ref<Fruit[]>(defaultData)
const localStorageFruitList = localStorage.getItem('fruitList')
if (localStorageFruitList && localStorageFruitList !== '[]') {fruitList.value = JSON.parse(localStorageFruitList)
}// 删除商品
const delGoods = (id: number) => {fruitList.value = fruitList.value.filter((item) => item.id !== id)
}
// 添加
const addGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num++
}
// 减少
const subGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num--
}// 全选
const checkAll = computed({get() {return fruitList.value.every((item) => item.isChecked)},set(value) {fruitList.value.forEach((item) => (item.isChecked = value))}
})// 统计选中的总数 reduce
const totalCount = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {// 选中 → 需要累加return sum + item.num} else {// 没选中 → 不需要累加return sum}}, 0)
})// 总计选中的总价 num * price
const totalPrice = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {return sum + item.num * item.price} else {return sum}}, 0)
})// 数据持久化方法
const saveData = () => {localStorage.setItem('fruitList', JSON.stringify(fruitList.value))
}
const getData = () => {const fruitListStr = localStorage.getItem('fruitList')
}
// 删除持久化
const delData = () => {localStorage.removeItem('fruitList')
}
// 清空持久化数据
const clearData = () => {localStorage.clear()
}
// 监听
watch(() => fruitList.value, saveData, { deep: true, immediate: true })
</script><template><div class="app-container" id="app"><!-- 顶部banner --><div class="banner-box"><img src="https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/sg_top.png" alt="" /></div><!-- 面包屑 --><div class="breadcrumb"><span>🏠</span>/<span>购物车</span></div><!-- 购物车主体 --><div v-if="fruitList.length > 0" class="main"><div class="table"><!-- 头部 --><div class="thead"><div class="tr"><div class="th">选中</div><div class="th th-pic">图片</div><div class="th">单价</div><div class="th num-th">个数</div><div class="th">小计</div><div class="th">操作</div></div></div><!-- 身体 --><div class="tbody"><divv-for="item in fruitList":key="item.id"class="tr":class="{ active: item.isChecked }"><div class="td"><input type="checkbox" v-model="item.isChecked" /></div><div class="td"><img :src="item.icon" alt="" /></div><div class="td">{{ item.price }}</div><div class="td"><div class="my-input-number"><button :disabled="item.num <= 1" class="decrease" @click="subGoods(item.id)">-</button><span class="my-input__inner">{{ item.num }}</span><button class="increase" @click="addGoods(item.id)">+</button></div></div><div class="td">{{ item.price * item.num }}</div><div class="td" @click="delGoods(item.id)"><button>删除</button></div></div></div></div><!-- 底部 --><div class="bottom"><!-- 全选 --><label class="check-all"><input type="checkbox" v-model="checkAll" />全选</label><div class="right-box"><!-- 所有商品总价 --><span class="price-box">总价&nbsp;&nbsp;:&nbsp;&nbsp;¥&nbsp;<span class="price">{{ totalPrice }}</span></span><!-- 结算按钮 --><button class="pay">结算( {{ totalCount }} )</button></div></div></div><!-- 空车 --><div v-else class="empty">🛒空空如也</div></div>
</template><style scoped>
@import './style/inputnumber.css';
@import './style/index.css';
</style>

总结

相关文章:

【Vue】- ref获取DOM元素和购物车案例分析

文章目录 知识回顾前言源码分析1. ref2. 购物车案例分析3. 购物车计算、全选 拓展知识数据持久化localStorage 总结 知识回顾 前言 元素上使用 ref属性关联响应式数据&#xff0c;获取DOM元素 步骤 ● 创建 ref > const hRef ref(null) ● 模板中建立关联 > <h1 re…...

【AI大模型】ChatGPT模型原理介绍(下)

目录 &#x1f354; GPT-3介绍 1.1 GPT-3模型架构 1.2 GPT-3训练核心思想 1.3 GPT-3数据集 1.4 GPT-3模型的特点 1.5 GPT-3模型总结 &#x1f354; ChatGPT介绍 2.1 ChatGPT原理 2.2 什么是强化学习 2.3 ChatGPT强化学习步骤 2.4 监督调优模型 2.5 训练奖励模型 2.…...

Python数据分析与可视化实战指南

在数据驱动的时代&#xff0c;Python因其简洁的语法、强大的库生态系统以及活跃的社区&#xff0c;成为了数据分析与可视化的首选语言。本文将通过一个详细的案例&#xff0c;带领大家学习如何使用Python进行数据分析&#xff0c;并通过可视化来直观呈现分析结果。 一、环境准…...

react18基础教程系列-- 框架基础理论知识mvc/jsx/createRoot

react的设计模式 React 是 mvc 体系&#xff0c;vue 是 mvvm 体系 mvc: model(数据)-view(视图)-controller(控制器) 我们需要按照专业的语法去构建 app 页面&#xff0c;react 使用的是 jsx 语法构建数据层&#xff0c;需要动态处理的的数据都要数据层支持控制层: 当我们需要…...

牛客周赛 Round 60 折返跑(组合数学)

题目链接&#xff1a;题目 大意&#xff1a; 在 1 1 1到 n n n之间往返跑m趟&#xff0c;推 m − 1 m-1 m−1次杆子&#xff0c;每次都向中间推&#xff0c;不能推零次&#xff0c;问有多少种推法&#xff08;mod 1e97&#xff09;。 思路&#xff1a; 一个高中学过的组合数…...

深入浅出Java匿名内部类:用法详解与实例演示

匿名内部类&#xff08;Anonymous Inner Class&#xff09;在Java中是一种非常有用的特性&#xff0c;它允许你在一个类的定义中直接创建并实例化一个内部类&#xff0c;而不需要为这个内部类指定一个名字。匿名内部类通常用于以下几种情况&#xff1a; 实现接口&#xff1a;当…...

数据库MySQL、Mariadb、PostgreSQL、MangoDB、Memcached和Redis详细介绍

以下是一些常见的后端开发数据库选型&#xff1a; 关系型数据库&#xff08;RDBMS&#xff09;&#xff1a;关系型数据库是最常见的数据库类型&#xff0c;使用表格和关系模型来存储和管理数据。常见的关系型数据库包括MySQL、PostgreSQL和Oracle等。这些数据库适合处理结构化数…...

【ArcGIS Pro实操第七期】栅格数据合并、裁剪及统计:以全球不透水面积为例

【ArcGIS Pro实操第七期】批量裁剪&#xff1a;以全球不透水面积为例 准备&#xff1a;数据下载ArcGIS Pro批量裁剪数据集1 数据拼接2 数据裁剪3 数据统计&#xff1a;各栅格取值3.1 栅格计算器-精确提取-栅格数据特定值3.2 数据统计 4 不透水面积变化分析 参考 准备&#xff1…...

【Linux】Image、zImage与uImage的区别

1、Image 1.1 什么是 Image Image 是一种未压缩的 Linux 内核镜像文件&#xff0c;包含了内核的所有代码、数据和必要的元信息。它是 Linux 内核在编译过程中生成的一个原始的二进制文件&#xff0c;未经过任何压缩或额外的封装处理。由于未压缩&#xff0c;Image 文件相对较…...

算子加速(3):自定义cuda扩展

需要自定义某个层,或有时候用c++实现你的操作(c++扩展)可能会更好: 例如:需要实现一个新型的激活函数例如: bevfusion用cuda实现bevpool加速自定义扩展的步骤 (1) 首先用纯pytorch和python 实现我们所需的功能,看看效果再决定要不要进一步优化(2) 明确优化方向,用C++ (或CU…...

信息安全数学基础(14)欧拉函数

前言 在信息安全数学基础中&#xff0c;欧拉函数&#xff08;Eulers Totient Function&#xff09;是一个非常重要的概念&#xff0c;它与模运算、剩余类、简化剩余系以及密码学中的许多应用紧密相关。欧拉函数用符号 φ(n) 表示&#xff0c;其中 n 是一个正整数。 一、定义 欧…...

7-17 汉诺塔的非递归实现

输入样例: 3输出样例: a -> c a -> b c -> b a -> c b -> a b -> c a -> c 分析&#xff1a; 不会汉罗塔的uu们&#xff0c;先看看图解&#xff1a; 非递归代码&#xff1a; #include<iostream> #include<stack> using namespace std; s…...

word文档无损原样转pdf在windows平台使用python调用win32com使用pip安装pywin32

前提&#xff1a; windows环境下&#xff0c;并且安装了office套装&#xff0c;比如word,如果需要调用excel.也需要安装。在另外的文章会介绍。这种是直接调用word的。所以还原度会比较高。 需求&#xff1a; word文档转pdf,要求使用命令行形式&#xff0c;最终发布为api接口…...

海康威视相机在QTcreate上的使用教程

文章目录 前言&#xff1a;基础夯实&#xff1a;效果展示&#xff1a;图片展示&#xff1a;视频展示&#xff1a; 参考的资料&#xff1a;遇到问题&#xff1a;问题1&#xff1a;int64 does not问题2&#xff1a;LNK2019配置思路(这个很重要)配置关键图片&#xff1a;配置具体过…...

进程状态、进程创建和进程分类

文章目录 进程进程常见的状态进程调度进程状态变化关系 进程标识示例--进程标识的使用以及简介 进程创建fork函数vfork函数示例--使用fork函数创建子进程&#xff0c;并了解进程之间的关系 创建进程时发生的变化虚拟内存空间的变化示例--验证fork函数创建进程时的操作 对文件IO…...

java后端请求调用三方接口

java后端请求调用三方接口 /*** param serverURL http接口地址&#xff08;例&#xff1a;http://www.iwsu.top:8016/dataSyn/bay/statsCar&#xff09;* param parm 参数&#xff08;可以是json&#xff0c;也可以是json数组&#xff09;*/ public void doRestfulPostBody(St…...

C#使用TCP-S7协议读写西门子PLC(三)

接上篇 C#使用TCP-S7协议读写西门子PLC(二)-CSDN博客 这里我们进行封装读写西门子PLC的S7协议命令以及连接西门子PLC并两次握手 新建部分类文件SiemensS7ProtocolUtil.ReadWrite.cs 主要方法&#xff1a; 连接西门子PLC并发送两次握手。两次握手成功后&#xff0c;才真正连…...

铝型材及其常用紧固件、连接件介绍

铝型材介绍&#xff08;包括紧固件和连接件以及走线&#xff09; 铝型材 铝型材一般是6063铝合金挤压成型&#xff0c;分为欧标和国标两个标准。&#xff08;左边国标&#xff0c;右边欧标&#xff0c;欧标槽宽一点&#xff09; 由于槽型不一样&#xff0c;相关的螺栓和螺母也…...

【裸机装机系列】7.kali(ubuntu)-安装开发所需工具

如果你是后端或是人工智能AI岗&#xff0c;可以安装以下推荐的软件&#xff1a; 1> sublime sublime官网 下载deb文件 安装命令 sudo dpkg -i sublime-text_build-4143_amd64.deb2> vscode 安装前置软件 sudo apt install curl gpg software-properties-common apt-t…...

[C语言]第九节 函数一基础知识到高级技巧的全景探索

目录 9.1 函数的概念 9.2 库函数 9.2.1 标准库与库函数 示例&#xff1a;常见库函数 9.2.2 标准库与头文件的关系 参考资料和学习工具 如何使用库函数 ​编辑 9.3 ⾃定义函数 9.3.1 函数的语法形式 9.3.2函数的举例 9.4 实参与形参 9.4.1 什么是实参&#xff1f; 9…...

第19节 Node.js Express 框架

Express 是一个为Node.js设计的web开发框架&#xff0c;它基于nodejs平台。 Express 简介 Express是一个简洁而灵活的node.js Web应用框架, 提供了一系列强大特性帮助你创建各种Web应用&#xff0c;和丰富的HTTP工具。 使用Express可以快速地搭建一个完整功能的网站。 Expre…...

国防科技大学计算机基础课程笔记02信息编码

1.机内码和国标码 国标码就是我们非常熟悉的这个GB2312,但是因为都是16进制&#xff0c;因此这个了16进制的数据既可以翻译成为这个机器码&#xff0c;也可以翻译成为这个国标码&#xff0c;所以这个时候很容易会出现这个歧义的情况&#xff1b; 因此&#xff0c;我们的这个国…...

谷歌浏览器插件

项目中有时候会用到插件 sync-cookie-extension1.0.0&#xff1a;开发环境同步测试 cookie 至 localhost&#xff0c;便于本地请求服务携带 cookie 参考地址&#xff1a;https://juejin.cn/post/7139354571712757767 里面有源码下载下来&#xff0c;加在到扩展即可使用FeHelp…...

synchronized 学习

学习源&#xff1a; https://www.bilibili.com/video/BV1aJ411V763?spm_id_from333.788.videopod.episodes&vd_source32e1c41a9370911ab06d12fbc36c4ebc 1.应用场景 不超卖&#xff0c;也要考虑性能问题&#xff08;场景&#xff09; 2.常见面试问题&#xff1a; sync出…...

【力扣数据库知识手册笔记】索引

索引 索引的优缺点 优点1. 通过创建唯一性索引&#xff0c;可以保证数据库表中每一行数据的唯一性。2. 可以加快数据的检索速度&#xff08;创建索引的主要原因&#xff09;。3. 可以加速表和表之间的连接&#xff0c;实现数据的参考完整性。4. 可以在查询过程中&#xff0c;…...

在 Nginx Stream 层“改写”MQTT ngx_stream_mqtt_filter_module

1、为什么要修改 CONNECT 报文&#xff1f; 多租户隔离&#xff1a;自动为接入设备追加租户前缀&#xff0c;后端按 ClientID 拆分队列。零代码鉴权&#xff1a;将入站用户名替换为 OAuth Access-Token&#xff0c;后端 Broker 统一校验。灰度发布&#xff1a;根据 IP/地理位写…...

【ROS】Nav2源码之nav2_behavior_tree-行为树节点列表

1、行为树节点分类 在 Nav2(Navigation2)的行为树框架中,行为树节点插件按照功能分为 Action(动作节点)、Condition(条件节点)、Control(控制节点) 和 Decorator(装饰节点) 四类。 1.1 动作节点 Action 执行具体的机器人操作或任务,直接与硬件、传感器或外部系统…...

【项目实战】通过多模态+LangGraph实现PPT生成助手

PPT自动生成系统 基于LangGraph的PPT自动生成系统&#xff0c;可以将Markdown文档自动转换为PPT演示文稿。 功能特点 Markdown解析&#xff1a;自动解析Markdown文档结构PPT模板分析&#xff1a;分析PPT模板的布局和风格智能布局决策&#xff1a;匹配内容与合适的PPT布局自动…...

《基于Apache Flink的流处理》笔记

思维导图 1-3 章 4-7章 8-11 章 参考资料 源码&#xff1a; https://github.com/streaming-with-flink 博客 https://flink.apache.org/bloghttps://www.ververica.com/blog 聚会及会议 https://flink-forward.orghttps://www.meetup.com/topics/apache-flink https://n…...

JDK 17 新特性

#JDK 17 新特性 /**************** 文本块 *****************/ python/scala中早就支持&#xff0c;不稀奇 String json “”" { “name”: “Java”, “version”: 17 } “”"; /**************** Switch 语句 -> 表达式 *****************/ 挺好的&#xff…...