HarmonyOs编写一个案例实现一个照片选择(阶段进阶 四种需求 逐一完善)
需求1. .实现照片选择 并将选择好的照片展示出来
import { GoodItem } from '../06/modules';@Entry
@Component
struct PhotoPage {@State message: string = '实现一个相册';@State List: GoodItem[] = [{goods_name: 'dsfjlsjkfsf',goods_price: 100,goods_img: 'https://img1.baidu.com/it/u=1535232938,2370569369&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800',goods_count: 1,id: 1},{goods_name: 'dfhlsdjflkdsjklfs 加速度的佛教山東i附件',goods_price: 200,goods_img: 'https://img1.baidu.com/it/u=2603934083,3021636721&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 2,id: 2},{goods_name: '收到回复技术大会哦恶化日发方大化工iu而韩国佛热',goods_price: 300,goods_img: 'https://img0.baidu.com/it/u=4289818793,3552718550&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 3,id: 3}, {goods_name: '的時間佛薩飛機埃里克森放假哦i二fore多氟多化工i額方法過後i額外人',goods_price: 400,goods_img: 'https://img0.baidu.com/it/u=2080725050,2021436341&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=800',goods_count: 4,id: 4}, {goods_name: '时间佛ID分机构IE',goods_price: 500,goods_img: 'https://img1.baidu.com/it/u=4202924242,2178453218&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800',goods_count: 5,id: 5}, {goods_name: '司法鉴定哦is叫哦私人',goods_price: 600,goods_img: 'https://10wallpaper.com/wallpaper/1680x1050/1405/Lavender_mountain_river-Landscape_HD_Wallpaper_1680x1050.jpg',goods_count: 6,id: 6}]@State isShowPhotoCom: boolean = false@State maxSelectNum: number = 4@State showSelectImgs: GoodItem[] = []build() {Column() {Button('选择图片').onClick(() => {this.isShowPhotoCom = true})Grid() {ForEach(this.showSelectImgs, (item: GoodItem, index) => {GridItem() {Image(item.goods_img).aspectRatio(1)}})}.columnsTemplate('1fr 1fr').columnsGap(4).rowsGap(4)if (this.isShowPhotoCom) {photoCom({List: this.List,isShowPhotoCom: this.isShowPhotoCom,maxSelectNum: this.maxSelectNum,showSelectImgs: this.showSelectImgs})}}.height('100%').width('100%')}
}@Component
struct photoCom {@Prop List: GoodItem[] = []@Link isShowPhotoCom: boolean@State selectList: GoodItem[] = []@Prop maxSelectNum: number@Link showSelectImgs: GoodItem[]// 选择图片逻辑selectFn(item: GoodItem) {let Index = this.selectList.findIndex(obj => obj.id == item.id)console.log(JSON.stringify(Index))if (Index > -1) {this.selectList.splice(Index, 1)} else {this.selectList.push(item)}}build() {Column() {Grid() {ForEach(this.List, (item: GoodItem, index) => {GridItem() {Stack() {Image(item.goods_img).aspectRatio(1)if (this.selectList.some(obj => obj.id == item.id)) {Image($r('app.media.select')).width(60).height(60).fillColor(Color.Red)}}.onClick(() => {this.selectFn(item)})}})}.columnsTemplate('1fr 1fr').layoutWeight(1)// Text(`${}/${}`)Row() {Button('取消').onClick(() => {this.isShowPhotoCom = false})Text(`已选${this.selectList.length}张/最多选择${this.maxSelectNum}张`)Button('确认').onClick(() => {this.showSelectImgs = this.selectListthis.isShowPhotoCom = false})}.width('100%').height(60).justifyContent(FlexAlign.SpaceAround)}.position({ x: 0, y: 0 }).width('100%').height('100%').backgroundColor(Color.White).justifyContent(FlexAlign.SpaceBetween)}
}
这个案例用到了父子传参@Prop @Link @State 各种样式交互 有兴趣可敲着玩玩~
我们看下效果
点击按钮
出现这个页面
然后执行选中逻辑
然后点击确认关闭弹窗
需求2. 点击图片实现预览效果(CustomDilog)
import { GoodItem } from '../06/modules';@Entry
@Component
struct PhotoPage {@State message: string = '实现一个相册';@State List: GoodItem[] = [{goods_name: 'dsfjlsjkfsf',goods_price: 100,goods_img: 'https://img1.baidu.com/it/u=1535232938,2370569369&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800',goods_count: 1,id: 1},{goods_name: 'dfhlsdjflkdsjklfs 加速度的佛教山東i附件',goods_price: 200,goods_img: 'https://img1.baidu.com/it/u=2603934083,3021636721&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 2,id: 2},{goods_name: '收到回复技术大会哦恶化日发方大化工iu而韩国佛热',goods_price: 300,goods_img: 'https://img0.baidu.com/it/u=4289818793,3552718550&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 3,id: 3}, {goods_name: '的時間佛薩飛機埃里克森放假哦i二fore多氟多化工i額方法過後i額外人',goods_price: 400,goods_img: 'https://img0.baidu.com/it/u=2080725050,2021436341&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=800',goods_count: 4,id: 4}, {goods_name: '时间佛ID分机构IE',goods_price: 500,goods_img: 'https://img1.baidu.com/it/u=4202924242,2178453218&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800',goods_count: 5,id: 5}, {goods_name: '司法鉴定哦is叫哦私人',goods_price: 600,goods_img: 'https://10wallpaper.com/wallpaper/1680x1050/1405/Lavender_mountain_river-Landscape_HD_Wallpaper_1680x1050.jpg',goods_count: 6,id: 6}]@State isShowPhotoCom: boolean = false@State maxSelectNum: number = 4@State showSelectImgs: GoodItem[] = []@State selectImage: ResourceStr | string = ''previw: CustomDialogController = new CustomDialogController({builder: PreviewDilog({ url: this.selectImage }),customStyle: true})build() {Column() {Button('选择图片').onClick(() => {this.isShowPhotoCom = true})Grid() {ForEach(this.showSelectImgs, (item: GoodItem, index) => {GridItem() {Image(item.goods_img).aspectRatio(1).onClick(() => {this.selectImage = item.goods_imgthis.previw.open()})}})}.columnsTemplate('1fr 1fr').columnsGap(4).rowsGap(4)if (this.isShowPhotoCom) {photoCom({List: this.List,isShowPhotoCom: this.isShowPhotoCom,maxSelectNum: this.maxSelectNum,showSelectImgs: this.showSelectImgs})}}.height('100%').width('100%')}
}@Component
struct photoCom {@Prop List: GoodItem[] = []@Link isShowPhotoCom: boolean@State selectList: GoodItem[] = []@Prop maxSelectNum: number@Link showSelectImgs: GoodItem[]// 选择图片逻辑selectFn(item: GoodItem) {let Index = this.selectList.findIndex(obj => obj.id == item.id)console.log(JSON.stringify(Index))if (Index > -1) {this.selectList.splice(Index, 1)} else {this.selectList.push(item)}}build() {Column() {Grid() {ForEach(this.List, (item: GoodItem, index) => {GridItem() {Stack() {Image(item.goods_img).aspectRatio(1)if (this.selectList.some(obj => obj.id == item.id)) {Image($r('app.media.select')).width(60).height(60).fillColor(Color.Red)}}.onClick(() => {this.selectFn(item)})}})}.columnsTemplate('1fr 1fr').layoutWeight(1)// Text(`${}/${}`)Row() {Button('取消').onClick(() => {this.isShowPhotoCom = false})Text(`已选${this.selectList.length}张/最多选择${this.maxSelectNum}张`)Button('确认').onClick(() => {this.showSelectImgs = this.selectListthis.isShowPhotoCom = false})}.width('100%').height(60).justifyContent(FlexAlign.SpaceAround)}.position({ x: 0, y: 0 }).width('100%').height('100%').backgroundColor(Color.White).justifyContent(FlexAlign.SpaceBetween)}
}@CustomDialog
struct PreviewDilog {controller: CustomDialogController = new CustomDialogController({ builder: CustomDialogController })url: ResourceStr | string = ''build() {Column() {Image(this.url).width('100%')}.width('100%').height('100%').backgroundColor(Color.Black).justifyContent(FlexAlign.Center).onClick(() => {this.controller.close()})}
}
圈下重点代码部分
子组件的
父组件的
需求3.HarmonyOs半模态bindsheet编写一个案例实现一个照片选择
import { GoodItem } from '../06/modules';@Entry
@Component
struct PhotoCasePage {@State message: string = '实现一个相册';@State List: GoodItem[] = [{goods_name: 'dsfjlsjkfsf',goods_price: 100,goods_img: 'https://img1.baidu.com/it/u=1535232938,2370569369&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800',goods_count: 1,id: 1},{goods_name: 'dfhlsdjflkdsjklfs 加速度的佛教山東i附件',goods_price: 200,goods_img: 'https://img1.baidu.com/it/u=2603934083,3021636721&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 2,id: 2},{goods_name: '收到回复技术大会哦恶化日发方大化工iu而韩国佛热',goods_price: 300,goods_img: 'https://img0.baidu.com/it/u=4289818793,3552718550&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 3,id: 3}, {goods_name: '的時間佛薩飛機埃里克森放假哦i二fore多氟多化工i額方法過後i額外人',goods_price: 400,goods_img: 'https://img0.baidu.com/it/u=2080725050,2021436341&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=800',goods_count: 4,id: 4}, {goods_name: '时间佛ID分机构IE',goods_price: 500,goods_img: 'https://img1.baidu.com/it/u=4202924242,2178453218&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800',goods_count: 5,id: 5}, {goods_name: '司法鉴定哦is叫哦私人',goods_price: 600,goods_img: 'https://10wallpaper.com/wallpaper/1680x1050/1405/Lavender_mountain_river-Landscape_HD_Wallpaper_1680x1050.jpg',goods_count: 6,id: 6}]@State isShowPhotoCom: boolean = false@State maxSelectNum: number = 4@State showSelectImgs: GoodItem[] = []@State selectImage: ResourceStr | string = ''previw: CustomDialogController = new CustomDialogController({builder: PreviewDilog({ url: this.selectImage }),customStyle: true})@BuildersheetBuilder() {Column() {photoCom({List: this.List,isShowPhotoCom: this.isShowPhotoCom,maxSelectNum: this.maxSelectNum,showSelectImgs: this.showSelectImgs})}}build() {Column() {Button('选择图片').onClick(() => {this.isShowPhotoCom = true})Grid() {ForEach(this.showSelectImgs, (item: GoodItem, index) => {GridItem() {Image(item.goods_img).aspectRatio(1).onClick(() => {this.selectImage = item.goods_imgthis.previw.open()})}})}.columnsTemplate('1fr 1fr').columnsGap(4).rowsGap(4)}.height('100%').width('100%').bindSheet(this.isShowPhotoCom, this.sheetBuilder, {showClose: false})}
}// 选择图片组件
@Component
struct photoCom {@Prop List: GoodItem[] = []@Link isShowPhotoCom: boolean@State selectList: GoodItem[] = []@Prop maxSelectNum: number@Link showSelectImgs: GoodItem[]// 选择图片逻辑selectFn(item: GoodItem) {let Index = this.selectList.findIndex(obj => obj.id == item.id)console.log(JSON.stringify(Index))if (Index > -1) {this.selectList.splice(Index, 1)} else {this.selectList.push(item)}}build() {Column() {Grid() {ForEach(this.List, (item: GoodItem, index) => {GridItem() {Stack() {Image(item.goods_img).aspectRatio(1)if (this.selectList.some(obj => obj.id == item.id)) {Image($r('app.media.select')).width(60).height(60).fillColor(Color.Red)}}.onClick(() => {this.selectFn(item)})}})}.columnsTemplate('1fr 1fr').layoutWeight(1)// Text(`${}/${}`)Row() {Button('取消').onClick(() => {this.isShowPhotoCom = false})Text(`已选${this.selectList.length}张/最多选择${this.maxSelectNum}张`)Button('确认').onClick(() => {this.showSelectImgs = this.selectListthis.isShowPhotoCom = false})}.width('100%').height(60).justifyContent(FlexAlign.SpaceAround)}.width('100%').height('100%').backgroundColor(Color.White).justifyContent(FlexAlign.SpaceBetween)}
}// 查看图片的组件
@CustomDialog
struct PreviewDilog {controller: CustomDialogController = new CustomDialogController({ builder: CustomDialogController })url: ResourceStr | string = ''build() {Column() {Image(this.url).width('100%')}.width('100%').height('100%').backgroundColor(Color.Black).justifyContent(FlexAlign.Center).onClick(() => {this.controller.close()})}
}
与上一篇的不同之处就在于 这篇代码使用了半模态弹层 就是点击选择图片之后 弹窗是从底部弹起的 类似于ios那种效果
重点代码截图
需求4. HarmonyOs半模态bindsheet编写一个案例实现一个照片选择并可swiper滑动 并实现点那张展开就是哪张
import { GoodItem } from '../06/modules';@Entry
@Component
struct PhotoCasePage {@State message: string = '实现一个半模态相册';@State List: GoodItem[] = [{goods_name: 'dsfjlsjkfsf',goods_price: 100,goods_img: 'https://img1.baidu.com/it/u=1535232938,2370569369&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800',goods_count: 1,id: 1},{goods_name: 'dfhlsdjflkdsjklfs 加速度的佛教山東i附件',goods_price: 200,goods_img: 'https://img1.baidu.com/it/u=2603934083,3021636721&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 2,id: 2},{goods_name: '收到回复技术大会哦恶化日发方大化工iu而韩国佛热',goods_price: 300,goods_img: 'https://img0.baidu.com/it/u=4289818793,3552718550&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',goods_count: 3,id: 3}, {goods_name: '的時間佛薩飛機埃里克森放假哦i二fore多氟多化工i額方法過後i額外人',goods_price: 400,goods_img: 'https://img0.baidu.com/it/u=2080725050,2021436341&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=800',goods_count: 4,id: 4}, {goods_name: '时间佛ID分机构IE',goods_price: 500,goods_img: 'https://img1.baidu.com/it/u=4202924242,2178453218&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800',goods_count: 5,id: 5}, {goods_name: '司法鉴定哦is叫哦私人',goods_price: 600,goods_img: 'https://10wallpaper.com/wallpaper/1680x1050/1405/Lavender_mountain_river-Landscape_HD_Wallpaper_1680x1050.jpg',goods_count: 6,id: 6}]@State isShowPhotoCom: boolean = false@State maxSelectNum: number = 4@State showSelectImgs: GoodItem[] = []@State selectImage: ResourceStr | string = ''@State setlectIndex: number = 0previw: CustomDialogController = new CustomDialogController({builder: PreviewDilog({ url: this.showSelectImgs, setlectIndex: this.setlectIndex, }),customStyle: true})@BuildersheetBuilder() {Column() {photoCom({List: this.List,isShowPhotoCom: this.isShowPhotoCom,maxSelectNum: this.maxSelectNum,showSelectImgs: this.showSelectImgs})}}build() {Column() {Button('选择图片').onClick(() => {this.isShowPhotoCom = true})Grid() {ForEach(this.showSelectImgs, (item: GoodItem, index: number) => {GridItem() {Image(item.goods_img).aspectRatio(1).onClick(() => {this.setlectIndex = indexthis.previw.open()})}})}.columnsTemplate('1fr 1fr').columnsGap(4).rowsGap(4)}.height('100%').width('100%').bindSheet($$this.isShowPhotoCom, this.sheetBuilder, {showClose: false})}
}// 选择图片组件
@Component
struct photoCom {@Prop List: GoodItem[] = []@Link isShowPhotoCom: boolean@State selectList: GoodItem[] = []@Prop maxSelectNum: number@Link showSelectImgs: GoodItem[]// 选择图片逻辑selectFn(item: GoodItem) {let Index = this.selectList.findIndex(obj => obj.id == item.id)console.log(JSON.stringify(Index))if (Index > -1) {this.selectList.splice(Index, 1)} else {this.selectList.push(item)}}build() {Column() {Grid() {ForEach(this.List, (item: GoodItem, index) => {GridItem() {Stack() {Image(item.goods_img).aspectRatio(1)if (this.selectList.some(obj => obj.id == item.id)) {Image($r('app.media.select')).width(60).height(60).fillColor(Color.Red)}}.onClick(() => {this.selectFn(item)})}})}.columnsTemplate('1fr 1fr').layoutWeight(1)// Text(`${}/${}`)Row() {Button('取消').onClick(() => {this.isShowPhotoCom = false})Text(`已选${this.selectList.length}张/最多选择${this.maxSelectNum}张`)Button('确认').onClick(() => {this.showSelectImgs = this.selectListthis.isShowPhotoCom = false})}.width('100%').height(60).justifyContent(FlexAlign.SpaceAround)}.width('100%').height('100%').backgroundColor(Color.White).justifyContent(FlexAlign.SpaceBetween)}
}// 查看图片的组件
@CustomDialog
struct PreviewDilog {controller: CustomDialogController = new CustomDialogController({ builder: CustomDialogController })url: GoodItem[] = []@Link setlectIndex: numberbuild() {Column() {Swiper() {ForEach(this.url, (item: GoodItem) => {Image(item.goods_img).width('100%')})}.loop(true).index($$this.setlectIndex)}.width('100%').height('100%').backgroundColor(Color.Black).justifyContent(FlexAlign.Center).onClick(() => {this.controller.close()})}
}
重点代码部分
注:传值发生了改变 在之前传值是传一张 然后再半模态显示出来 现在是传选中的那个数组 然后记录下点击的那个index 里边用swiper组件就可以了
相关文章:

HarmonyOs编写一个案例实现一个照片选择(阶段进阶 四种需求 逐一完善)
需求1. .实现照片选择 并将选择好的照片展示出来 import { GoodItem } from ../06/modules;Entry Component struct PhotoPage {State message: string 实现一个相册;State List: GoodItem[] [{goods_name: dsfjlsjkfsf,goods_price: 100,goods_img: https://img1.baidu.com…...

洗衣机洗衣服一些知识
01智能:按衣物多少自动调节合适水位的标准洗涤程序 (需要30分钟时间) 02:大物:较大,较厚的衣服洗涤 03:轻柔:毛织品或内衣洗涤 04:快速:少量清污衣服洗涤 (13分钟) 05:浸泡:先浸泡一段时间再洗涤 06:单洗:只洗衣不脱水 07:单脱:只脱水不洗衣 08:洁桶:清洁洗衣桶 准备工作: (1)…...

探索文件系统:高效、可靠的文件管理与访问机制
文件系统的功能规划 内存就像是一个书包,容量有限,只能带着一部分东西。而图书馆则是一个专门存储和管理文件的地方,拥有更大的容量,并且可以永久保存文件。为了能够快速找到需要的文件,我们需要有一个书单来记录每本…...

启程与远征Ⅸ--优化生成式人工智能以满足业务需求的框架
生成类似人类的文本和语音曾经只存在于科幻小说中。但 GPT-3 和 PaLM 等大型语言模型 (LLM) 的快速发展让这一愿景更接近现实,解锁了从聊天机器人到内容创作等一系列有前景的商业应用。 然而,通用基础模型往往无法满足行业用例的需求。企业对其生成式 A…...

canal数据同步工具介绍与应用
canal服务 canal介绍canal版本与环境canal 服务集canal应用场景: canal常见问题xml配置问题连接认证问题jar版本问题连接问题 canal介绍 1、Canal是阿里巴巴开源的MySQL增量数据订阅和消费工具,通过模拟MySQL的slave与master交互,捕…...

ubuntu18.04 设置静态地址
修改配置文件 sudo vim /etc/netplan/01-network-manager-all.yaml 代码如下: network: version: 2 renderer: NetworkManager ethernets: ens33: # 配置的网卡名称,可以使用ifconfig -a查看本机的网卡 dhcp4: no # 关闭动态IP设置 …...

jira敏捷开发管理工具视频教程Confluence工作流协同开发(2024)
正文: 随着Jira敏捷开发方法论的普及,Jira已经成为全球软件开发团队管理项目、任务和问题的首选工具。为了帮助团队更好地掌握Jira的核心功能,精心准备了一套全面开发技术及案例视频教程——《Jira敏捷开发管理工具视频教程Confluenc…...
【网络】TCP回显服务器和客户端的构造,以及相关bug解决方法
文章目录 ServerSocket构造方法方法 Socket构造方法方法 回显服务器(Echo Server)1. 构造方法2. 建立连接processConnection 方法的创建1. 读取请求并解析2. 根据请求计算响应3. 把响应写回给客户端 3. 完整代码 客户端(Echo Clientÿ…...
Python知识点:如何使用Boto3进行AWS服务管理
使用 boto3 来管理 AWS 服务是一个非常强大的方式,因为 boto3 是 AWS 提供的官方 Python SDK。下面是使用 boto3 管理 AWS 服务的基本步骤,包括设置、操作和常见的 AWS 服务示例。 1. 安装 boto3 首先,确保你已经安装了 boto3。可以使用 pi…...

Java - 正则表达式
Java 提供了 java.util.regex 包,它包含了 Pattern 和 Matcher 类,用于处理正则表达式的匹配操作。 正则表达式的模式 正则表达式的模式可以包括以下内容: 字面值字符:例如字母、数字、空格等,可以直接匹配它们自身。…...

Vue一款流行的JavaScript前端框架
1.Vue简介 Vue是一款用于构建用户界面的 JavaScript 框架。它基于标准 HTML、CSS 和 JavaScript 构建,并提供了一套声明式的、组件化的编程模型,帮助你高效地开发用户界面。无论是简单还是复杂的界面,Vue 都可以胜任。 Vue所关注的核心是MVC…...

GPT-SoVITS
文章目录 model archS1 ModelS2 model model arch S1 model: AR model–ssl tokensS2 model: VITS,ssl 已经是mel 长度线性相关,MRTE(ssl_codes_embs, text, global_mel_emb)模块,将文本加强相关,学到一个参考结果 S1 Model cla…...
linux高级编程——文件IO(常用函数大全)
1.相关介绍及常用函数 Linux高级编程中的目录IO操作是文件系统编程的一个重要组成部分,主要涉及到目录的打开、读取、遍历和关闭等操作。以下是一些基本的目录IO操作和相关的系统调用函数 1.1 opendir函数 打开目录:使用opendir函数打开一个目录&#…...

matplotlib画图
Matplotlib 先写一个最简单的: import matplotlib.pyplot as plt plt.plot([1,4],[2,8]) #plot画折线图plt.show() 确定两个点画一条线 import matplotlib.pyplot as plt x[1,23,4,56,7,6] #x轴数据 y[22,44,56,67,43,2] #y轴数据 s[22,43,33,44,43,7] plt.p…...

Jetpack 各种框架简介
Jetpack是Google推出的一套为Android开发提供极大便利的组件、工具和指导集,旨在帮助开发者快速构建高质量的应用,并遵循最佳实践。 Jetpack不仅是一个提高开发效率的工具集,还是Android开发的未来方向。它通过整合各种组件和工具࿰…...

海康VisionMaster使用学习笔记5-开机自启动
开机自启动 在实际应用中,用户会希望机台上电开机后,软件能自启动避免现场人员误操作,减少机台重新上电时的操作步骤以提升效率。 设置 打开VM,点击设置,软件设置->开机自启动->勾选开机自启动->确定 默认运行界面 启动时以设定的…...
驾驭数据之序:SQL序列的奥秘与实现
标题:驾驭数据之序:SQL序列的奥秘与实现 摘要 在数据库管理中,保证数据的有序性和唯一性是至关重要的。SQL序列(Sequence)作为一种强大的数据库对象,为我们提供了一种在不同数据库系统中生成连续数字的手…...

【LeetCode】148. 排序链表
排序链表 题目描述: 给你链表的头结点 head ,请将其按 升序 排列并返回 排序后的链表 。 示例 1: 输入:head [4,2,1,3] 输出:[1,2,3,4]示例 2: 输入:head [-1,5,3,4,0] 输出:…...

阿里云-java调用短信服务,第三方接口的开启(傻瓜式教程)
第一步:在浏览器中,搜索阿里云 第二步:打开aly的主页 第三步:在最上方的导航栏中,找到云市场,注意不要点击,会自动有触发悬浮框出现,在悬浮框中找到 短信 第四步:点击 短…...

以node / link文件表征的道路网络-----基于南京公路公开数据做路径规划(下)------dijkstra算法的一些简单花样
在不改变dijkstra算法本身的情况下,完全可以从数据源的角度出发,解决我们的一些简单需求: 比较初级且粗暴的玩法,可以是强行赋予一些link极端的路段长度。 对于我们坚决不希望车辆行驶的道路、禁行区、或是危险区,就…...

C++_核心编程_多态案例二-制作饮品
#include <iostream> #include <string> using namespace std;/*制作饮品的大致流程为:煮水 - 冲泡 - 倒入杯中 - 加入辅料 利用多态技术实现本案例,提供抽象制作饮品基类,提供子类制作咖啡和茶叶*//*基类*/ class AbstractDr…...

iOS 26 携众系统重磅更新,但“苹果智能”仍与国行无缘
美国西海岸的夏天,再次被苹果点燃。一年一度的全球开发者大会 WWDC25 如期而至,这不仅是开发者的盛宴,更是全球数亿苹果用户翘首以盼的科技春晚。今年,苹果依旧为我们带来了全家桶式的系统更新,包括 iOS 26、iPadOS 26…...
树莓派超全系列教程文档--(62)使用rpicam-app通过网络流式传输视频
使用rpicam-app通过网络流式传输视频 使用 rpicam-app 通过网络流式传输视频UDPTCPRTSPlibavGStreamerRTPlibcamerasrc GStreamer 元素 文章来源: http://raspberry.dns8844.cn/documentation 原文网址 使用 rpicam-app 通过网络流式传输视频 本节介绍来自 rpica…...

黑马Mybatis
Mybatis 表现层:页面展示 业务层:逻辑处理 持久层:持久数据化保存 在这里插入图片描述 Mybatis快速入门 
CocosCreator 之 JavaScript/TypeScript和Java的相互交互
引擎版本: 3.8.1 语言: JavaScript/TypeScript、C、Java 环境:Window 参考:Java原生反射机制 您好,我是鹤九日! 回顾 在上篇文章中:CocosCreator Android项目接入UnityAds 广告SDK。 我们简单讲…...
【JavaSE】绘图与事件入门学习笔记
-Java绘图坐标体系 坐标体系-介绍 坐标原点位于左上角,以像素为单位。 在Java坐标系中,第一个是x坐标,表示当前位置为水平方向,距离坐标原点x个像素;第二个是y坐标,表示当前位置为垂直方向,距离坐标原点y个像素。 坐标体系-像素 …...

Map相关知识
数据结构 二叉树 二叉树,顾名思义,每个节点最多有两个“叉”,也就是两个子节点,分别是左子 节点和右子节点。不过,二叉树并不要求每个节点都有两个子节点,有的节点只 有左子节点,有的节点只有…...
大语言模型(LLM)中的KV缓存压缩与动态稀疏注意力机制设计
随着大语言模型(LLM)参数规模的增长,推理阶段的内存占用和计算复杂度成为核心挑战。传统注意力机制的计算复杂度随序列长度呈二次方增长,而KV缓存的内存消耗可能高达数十GB(例如Llama2-7B处理100K token时需50GB内存&a…...
Linux离线(zip方式)安装docker
目录 基础信息操作系统信息docker信息 安装实例安装步骤示例 遇到的问题问题1:修改默认工作路径启动失败问题2 找不到对应组 基础信息 操作系统信息 OS版本:CentOS 7 64位 内核版本:3.10.0 相关命令: uname -rcat /etc/os-rele…...

Yolov8 目标检测蒸馏学习记录
yolov8系列模型蒸馏基本流程,代码下载:这里本人提交了一个demo:djdll/Yolov8_Distillation: Yolov8轻量化_蒸馏代码实现 在轻量化模型设计中,**知识蒸馏(Knowledge Distillation)**被广泛应用,作为提升模型…...