目录

1. 组件状态共享

1.1 状态共享-父子传值:Local、Param、Event

1.2 状态共享-父子双向绑定!!

1.3 跨代共享:Provider和Consumer

1.3.1 aliasName和属性名

1.3.2 实现跨代共享

1.3.3 装饰复杂类型,配合@Trace一起使用

1.3.4 支持共享方法

1.4 @Monitor装饰器:状态变量修改监听

1.5 综合案例 - 相册图片选取

1.5.1 页面布局,准备一个选择图片的按钮并展示

1.5.2 准备弹层,点击时展示弹层

1.5.3 添加点击事件,设置选中状态

1.5.4 点击确定同步给页面

1.5.5 关闭弹层


1. 组件状态共享

1.1 状态共享-父子传值:Local、Param、Event

  • @Param表示组件从外部传入的状态,使得父子组件之间的数据能够进行同步
  • @Param装饰的变量支持本地初始化,但是不允许在组件内部直接修改变量本身
  • 若不在本地初始化,则需要和@Require装饰器一起使用,要求必须从外部传入初始化
  • 如果要修改值需使用@Event装饰器的能力。

父传子强化:

@Entry@ComponentV2struct ComponentQuestionCase {@Local money: number = 9999;build() {Column() {Text('father:' + this.money)Button('父亲存100块').onClick(()=>{this.money += 100})CompQsChild({money:this.money}).margin({ bottom: 30 })CompQsChild({money:this.money})}.padding(20).width('80%').margin(30).border({ width: 2 })}}@ComponentV2struct CompQsChild {// 若不在本地初始化,则需和@Require装饰器一起使用,要求必须从外部传入初始化@Require @Param money: numberbuild() {Column() {Text('child:' + this.money)Button('花100块').onClick(()=>{// @Param表示组件从外部传入的状态// 1. 父子组件之间的数据能够进行同步// 2. 不允许在组件内部直接修改变量本身//    修改值需使用@Event装饰器的能力// this.money -= 100})}.padding(20).backgroundColor(Color.Pink)}}

  • 为了实现子组件向父组件要求更新@Param装饰变量的能力,开发者可以使用@Event装饰器。
  • 使用@Event装饰回调方法是一种规范,表明子组件需要传入更新数据源的回调。
  • @Event主要配合@Param实现数据的双向同步。

子传父强化:

@Entry@ComponentV2struct ComponentQuestionCase {@Local money: number = 9999;build() {Column() {Text('father:' + this.money)Button('父亲存100块').onClick(()=>{this.money += 100})CompQsChild({money:this.money,payMoney: () => {this.money -= 10}}).margin({ bottom: 30 })CompQsChild({money:this.money,payMoney: () => {this.money -= 10}})}.padding(20).width('80%').margin(30).border({ width: 2 })}}@ComponentV2struct CompQsChild {// 若不在本地初始化,则需和@Require装饰器一起使用,要求必须从外部传入初始化@Require @Param money: number@Event payMoney: () => void = () => {}build() {Column() {Text('child:' + this.money)Button('花10块').onClick(()=>{// @Param表示组件从外部传入的状态// 1. 父子组件之间的数据能够进行同步// 2. 不允许在组件内部直接修改变量本身//    修改值需使用@Event装饰器的能力// this.money -= 100this.payMoney()})}.padding(20).backgroundColor(Color.Pink)}}

1.2 状态共享-父子双向绑定!!

场景:组件二次封装 (输入框、下拉菜单....)

!!双向绑定语法,是一个语法糖方便实现数据双向绑定

其中@Event方法名需要声明为“$”+ @Param属性名。

@Entry@ComponentV2struct Test {@Local words: string = 'admin'build() {Column({ space: 20 }) {CustomizeInput({text: this.words!!})Text('输入框内容: ' + this.words)}.padding(20)}}@ComponentV2struct CustomizeInput {@Param text: string = ''@Event $text: (val: string) => void = (val: string) => {};build() {Column() {TextInput({text: this.text}).border({ width: 2, color: Color.Blue }).onChange((value) => {this.$text(value)})}}}

简化逻辑:

CustomizeInput({text: this.words!!
})
CustomizeInput({ text: this.words, $text: (val: number) => { this.words = val }
})

1.3 跨代共享:Provider和Consumer

如果组件层级特别多,ArkTS支持跨组件传递状态数据来实现双向同步@Provider 和 @Consumer

  • @Provider,即数据提供方
    • 其所有的子组件都可以通过@Consumer绑定相同的key来获取@Provider提供的数据
  • @Consumer,即数据消费方
    • 可以通过绑定同样的key获取其最近父节点的@Provider的数据
    • 当查找不到@Provider的数据时,使用本地默认值。

@Provider和@Consumer装饰数据类型需要一致。

开发者在使用@Provider和@Consumer时要注意:

  • @Provider和@Consumer强依赖自定义组件层级,@Consumer会因为所在组件的父组件不同,而被初始化为不同的值。
  • @Provider和@Consumer相当于把组件粘合在一起了,从组件独立角度,要减少使用@Provider和@Consumer。

1.3.1 aliasName和属性名

@Provider和@Consumer接受可选参数aliasName,没有配置参数时,使用属性名作为默认的aliasName。

说明

aliasName是用于@Provider和@Consumer进行匹配的唯一指定key。

@ComponentV2
struct Parent {// 未定义aliasName, 使用属性名'str'作为aliasName@Provider() str: string = 'hello';
}@ComponentV2
struct Child {// 定义aliasName为'str',使用aliasName去寻找// 能够在Parent组件上找到, 使用@Provider的值'hello'@Consumer('str') str: string = 'world';
}

@ComponentV2
struct Parent {// 定义aliasName为'alias'@Provider('alias') str: string = 'hello';
}@ComponentV2 struct Child {// 定义aliasName为 'alias',找到@Provider并获得值'hello'@Consumer('alias') str: string = 'world';
}

1.3.2 实现跨代共享

  • 静态结构:
@Entry@ComponentV2struct ComponentQuestionCase1 {build() {Column() {Text('father: 20000')Button('存100块').onClick(() => {})CompQsChild1().margin({ top: 20 })}.padding(20).margin(30).border({ width: 2 }).width('80%')}}@ComponentV2struct CompQsChild1 {build() {Column() {Text('child儿子: xxx')Button('花100块').onClick(() => {})ChildChild1().margin({ top: 20 })}.padding(20).backgroundColor(Color.Pink)}}@ComponentV2struct ChildChild1 {build() {Column() {Text('ChildChild孙子: xxx')Button('花100块').onClick(() => {})}.padding(20).backgroundColor(Color.Orange)}}
  • 实现共享:
@Entry@ComponentV2struct ComponentQuestionCase1 {@Provider('totalMoney') money: number = 50000build() {Column() {Text('father: ' + this.money)Button('存100块').onClick(() => {this.money += 100})CompQsChild1().margin({ top: 20 })}.padding(20).margin(30).border({ width: 2 }).width('80%')}}@ComponentV2struct CompQsChild1 {@Consumer('totalMoney') money: number = 0build() {Column() {Text('child儿子: ' + this.money)Button('花100块').onClick(() => {this.money -= 100})ChildChild1().margin({ top: 20 })}.padding(20).backgroundColor(Color.Pink)}}@ComponentV2struct ChildChild1 {@Consumer('totalMoney') money: number = 0build() {Column() {Text('ChildChild孙子: ' + this.money)Button('花100块').onClick(() => {this.money -= 100})}.padding(20).backgroundColor(Color.Orange)}}
1.3.3 装饰复杂类型,配合@Trace一起使用

@Provider和@Consumer只能观察到数据本身的变化。

如果当其装饰复杂数据类型,需要观察属性的变化时,需要配合@Trace一起使用。

interface ICar {brand: stringprice: number
}@ObservedV2class Car {@Trace brand: string = '宝马'@Trace price: number = 200000constructor(obj: ICar) {this.brand = obj.brandthis.price = obj.price}}@Entry@ComponentV2struct ComponentQuestionCase2 {@Provider('totalMoney') money: number = 50000@Provider() car: Car = new Car({brand: '奔驰',price: 150000})build() {Column() {Text('father: ' + this.money)Text(this.car.brand + "_" + this.car.price)Row() {Button('存100块').onClick(() => {this.money += 100})Button('换车').onClick(() => {this.car.brand = '三轮车'})}CompQsChild2().margin({ top: 20 })}.padding(20).margin(30).border({ width: 2 }).width('80%')}}@ComponentV2struct CompQsChild2 {@Consumer('totalMoney') money: number = 0build() {Column() {Text('child儿子: ' + this.money)Button('花100块').onClick(() => {this.money -= 100})ChildChild2().margin({ top: 20 })}.padding(20).backgroundColor(Color.Pink)}}@ComponentV2struct ChildChild2 {@Consumer('totalMoney') money: number = 0@Consumer() car: Car = new Car({} as ICar)build() {Column() {Text('ChildChild孙子: ' + this.money)Text(this.car.brand + '_' + this.car.price)Row() {Button('花100块').onClick(() => {this.money -= 100})Button('换车').onClick(() => {this.car.brand = '小黄车'})}}.padding(20).backgroundColor(Color.Orange)}}

1.3.4 支持共享方法

当需要在父组件中向子组件注册回调函数时,可以使用@Provider和@Consumer装饰回调方法来解决。

比如输入提交,当输入提交时,如果希望将子孙组件提交的信息同步给父组件

可以参考下面的例子:

import { promptAction } from '@kit.ArkUI'@Entry
@ComponentV2
struct Parent {@Provider() onSubmit: (txt: string) => void = (txt: string) => {promptAction.showDialog({message: txt})}build() {Column() {Child()}}
}@ComponentV2
struct Child {@Local txt: string = ''@Consumer() onSubmit: (txt: string) => void = (txt: string) => {};build() {Column() {TextInput({ text: $$this.txt }).onSubmit(() => {this.onSubmit(this.txt)})}}
}

注意:@Provider重名时,@Consumer向上查找其最近的@Provider

1.4 @Monitor装饰器:状态变量修改监听

为了增强对状态变量变化的监听能力,开发者可以使用@Monitor装饰器对状态变量进行监听。

@Monitor装饰器用于监听状态变量修改,使得状态变量具有深度监听的能力

  • @Monitor装饰器支持在@ComponentV2装饰的自定义组件中使用,未被状态变量装饰器@Local@Param@Provider@Consumer@Computed装饰的变量无法被@Monitor监听到变化。
  • @Monitor装饰器支持在类中与@ObservedV2、@Trace配合使用,不允许在未被@ObservedV2装饰的类中使用@Monitor装饰器。未被@Trace装饰的属性无法被@Monitor监听到变化。
  • 单个@Monitor装饰器能够同时监听多个属性的变化,当这些属性在一次事件中共同变化时,只会触发一次@Monitor的回调方法。

@Monitor与@Watch对比:

基础语法:

@Entry
@ComponentV2
struct Index {@Local username: string = "帅鹏";@Local age: number = 24;@Monitor('username')onNameChange(monitor: IMonitor) {console.log('姓名变化了', this.username)}// 监视多个变量 / 拿到变化前的值// @Monitor("username", "age")// onInfoChange(monitor: IMonitor) {//   // monitor.dirty.forEach((path: string) => {//   //   console.log(`${path} changed from ${monitor.value(path)?.before} to ${monitor.value(path)?.now}`)//   // })//   // console.log(JSON.stringify(monitor.dirty))////   monitor.dirty.forEach((path: string) => {//     console.log(`${path}改变了, 从 ${monitor.value(path)?.before} 改成了 ${monitor.value(path)?.now}`)//   })// }build() {Column() {Text(this.username)Text(this.age.toString())Button("修改信息").onClick(() => {this.username = '张三'})}.width('100%')}
}

在@ObservedV2装饰的类中使用@Monitor:

import { promptAction } from '@kit.ArkUI';@ObservedV2
class Info {@Trace name: string = "吕布";age: number = 25;// name被@Trace装饰,能够监听变化@Monitor("name")onNameChange(monitor: IMonitor) {promptAction.showDialog({message: `姓名修改, 从 ${monitor.value()?.before} 改成了 ${monitor.value()?.now}`})}// age未被@Trace装饰,不能监听变化@Monitor("age")onAgeChange(monitor: IMonitor) {console.log(`年纪修改, 从 ${monitor.value()?.before} 改成了 ${monitor.value()?.now}`);}
}
@Entry
@ComponentV2
struct Index {info: Info = new Info();@Monitor('info.name')onNameChange () {promptAction.showDialog({message: this.info.name})}build() {Column() {Text(this.info.name + this.info.age)Button("修改名字").onClick(() => {this.info.name = "张飞"; // 能够触发onNameChange方法})Button("修改年纪").onClick(() => {this.info.age = 26; // 不能够触发onAgeChange方法})}}
}

1.5 综合案例 - 相册图片选取

基于我们已经学习过的父子、跨代、状态监听,我们来做一个综合案例

分析:

1.准备一个用于选择图片的按钮,点击展示弹层

2.准备弹层,渲染所有图片

3.图片添加点击事件,点击时检测选中数量后添加选中状态

4.点击确定,将选中图片同步给页面并关闭弹层

5.取消时,关闭弹层

1.5.1 页面布局,准备一个选择图片的按钮并展示

  • 选择图片Builder

@Builder
function SelectImageIcon() {Row() {Image($r('sys.media.ohos_ic_public_add')).width('100%').height('100%').fillColor(Color.Gray)}.width('100%').height('100%').padding(20).backgroundColor('#f5f7f8').border({width: 1,color: Color.Gray,style: BorderStyle.Dashed})
}

  • 页面布局,使用Builder

@Entry
@ComponentV2
struct ImageSelectCase {build() {Grid() {GridItem() {SelectImageIcon()}.aspectRatio(1)}.padding(20).width('100%').height('100%').rowsGap(10).columnsGap(10).columnsTemplate('1fr 1fr 1fr')}
}

1.5.2 准备弹层,点击时展示弹层

准备弹层组件:

@ComponentV2
struct SelectImage {@Param imageList:ResourceStr[] = []build() {Column() {Row() {Text('取消')Text('已选中 0/9 张').layoutWeight(1).textAlign(TextAlign.Center)Text('确定')}.width('100%').padding(20)Grid() {ForEach(this.imageList, (item: ResourceStr) => {GridItem() {Image(item)}.aspectRatio(1)})}.padding(20).layoutWeight(1).rowsGap(10).columnsGap(10).columnsTemplate('1fr 1fr 1fr')}.width('100%').height('100%').backgroundColor('#f5f7f8')}
}
export { SelectImage }

控制显示:

import { SelectImage } from '../components/SelectImage'
@Entry
@ComponentV2
struct ImageSelectCase {@Local showDialog: boolean = false@Local imageList: ResourceStr[] = ["assets/1.webp","assets/2.webp","assets/3.webp","assets/4.webp","assets/5.webp","assets/6.webp","assets/7.webp","assets/8.webp","assets/9.webp","assets/10.webp"]@BuilderImageListBuilder() {// 大坑:最外层必须得是容器组件Column(){SelectImage({imageList:this.imageList})}}build() {Grid() {GridItem() {SelectImageIcon()}.aspectRatio(1).onClick(() => {this.showDialog = true})}.padding(20).width('100%').height('100%').rowsGap(10).columnsGap(10).columnsTemplate('1fr 1fr 1fr').bindSheet($$this.showDialog, this.ImageListBuilder(), { showClose: false, height: '60%' })}
}@Builder
function SelectImageIcon() {Row() {Image($r('sys.media.ohos_ic_public_add')).width('100%').height('100%').fillColor(Color.Gray)}.width('100%').height('100%').padding(20).backgroundColor('#f5f7f8').border({width: 1,color: Color.Gray,style: BorderStyle.Dashed})
}
1.5.3 添加点击事件,设置选中状态

  • 对图片进行改造,统一添加点击事件,并声明一个选中的列表用来收集选中的图片

@ComponentV2
struct SelectImage {@Param imageList:ResourceStr[] = []@Local selectList: ResourceStr[] = []build() {Column() {Row() {Text('取消')Text(`已选中${this.selectList.length}/9 张`).layoutWeight(1).textAlign(TextAlign.Center)Text('确定')}.width('100%').padding(20)Grid() {ForEach(this.imageList, (item: ResourceStr) => {GridItem() {Stack({ alignContent: Alignment.BottomEnd }) {Image(item)if (this.selectList.includes(item)) {Image($r('sys.media.ohos_ic_public_select_all')).width(30).aspectRatio(1).fillColor('#ff397204').margin(4).backgroundColor(Color.White)}}}.aspectRatio(1).onClick(() => {this.selectList.push(item)})})}.padding(20).layoutWeight(1).rowsGap(10).columnsGap(10).columnsTemplate('1fr 1fr 1fr')}.width('100%').height('100%').backgroundColor('#f5f7f8')}
}
export { SelectImage }
  1. 已经选中, 再点击就是取消
  2. 没有选中, 再点击就是追加

.onClick(() => {if (this.selectList.includes(item)) {// 已经选中, 再点击就是取消this.selectList = this.selectList.filter(filterItem => filterItem !== item)}else {// 没有选中, 再点击就是追加this.selectList.push(item)}
})

1.5.4 点击确定同步给页面

  • 父组件传递数据下来,利用!!双向绑定

import { SelectImage } from '../components/SelectImage'@Entry
@ComponentV2
struct ImageSelectCase {@Local showDialog: boolean = false@Local imageList: ResourceStr[] = ["assets/1.webp","assets/2.webp","assets/3.webp","assets/4.webp","assets/5.webp","assets/6.webp","assets/7.webp","assets/8.webp","assets/9.webp","assets/10.webp"]@Local selectedList: ResourceStr[] = []@BuilderImageListBuilder() {// 大坑:最外层必须得是容器组件Column(){SelectImage({imageList: this.imageList,selectedList: this.selectedList!!})}}build() {Grid() {ForEach(this.selectedList,(item:ResourceStr)=>{GridItem() {Image(item)}.aspectRatio(1)})GridItem() {SelectImageIcon()}.aspectRatio(1).onClick(() => {this.showDialog = true})}.padding(20).width('100%').height('100%').rowsGap(10).columnsGap(10).columnsTemplate('1fr 1fr 1fr').bindSheet($$this.showDialog, this.ImageListBuilder(), { showClose: false, height: '60%' })}
}@Builder
function SelectImageIcon() {Row() {Image($r('sys.media.ohos_ic_public_add')).width('100%').height('100%').fillColor(Color.Gray)}.width('100%').height('100%').padding(20).backgroundColor('#f5f7f8').border({width: 1,color: Color.Gray,style: BorderStyle.Dashed})
}
  • 子组件接受处理

@ComponentV2
struct SelectImage {@Param imageList:ResourceStr[] = []@Local selectList: ResourceStr[] = []@Param selectedList: ResourceStr[] = []@Event $selectedList: (val: ResourceStr[]) => void = (val: ResourceStr[]) => {}build() {Column() {Row() {Text('取消')Text(`已选中${this.selectList.length}/9 张`).layoutWeight(1).textAlign(TextAlign.Center)Text('确定').onClick(() => {this.$selectedList([...this.selectList])})}.width('100%').padding(20)Grid() {ForEach(this.imageList, (item: ResourceStr) => {GridItem() {Stack({ alignContent: Alignment.BottomEnd }) {Image(item)if (this.selectList.includes(item)) {Image($r('sys.media.ohos_ic_public_select_all')).width(30).aspectRatio(1).fillColor('#ff397204').margin(4).backgroundColor(Color.White)}}}.aspectRatio(1).onClick(() => {if (this.selectList.includes(item)) {// 已经选中, 再点击就是取消this.selectList = this.selectList.filter(filterItem => filterItem !== item)}else {// 没有选中, 再点击就是追加this.selectList.push(item)}})})}.padding(20).layoutWeight(1).rowsGap(10).columnsGap(10).columnsTemplate('1fr 1fr 1fr')}.width('100%').height('100%').backgroundColor('#f5f7f8')}
}
export { SelectImage }

到这效果基本就完成了,最后一个关闭弹层,你能想到怎么做了吗?

1.5.5 关闭弹层

  • 父组件

@Builder
ImageListBuilder() {// 大坑:最外层必须得是容器组件Column(){SelectImage({showDialog: this.showDialog!!,imageList: this.imageList,selectedList: this.selectedList!!})}
}
  • 子组件

@Param showDialog: boolean = false
@Event $showDialog: (val: boolean) => void = (val: boolean) => {}Text('取消').onClick(() => {this.$showDialog(false)
})
  • 子组件渲染时,同步一下数据

aboutToAppear(): void {this.selectList = [...this.selectedList]
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/web/86957.shtml
繁体地址,请注明出处:http://hk.pswp.cn/web/86957.shtml
英文地址,请注明出处:http://en.pswp.cn/web/86957.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【MySQL】12. C语言与数据库的连接

1. 下载MySQL的连接库 sudo apt install -y libmysqlclient-dev 2. MySQL连接库的常用接口介绍 通过下面的样例了解MYSQL的常用接口&#xff1a; #include <iostream> #include <mysql/mysql.h> using namespace std;const char *host "localhost";…

[springboot系列] 探秘JUnit 5: Java单元测试利器

介绍 JUnit 5 是一个用于 Java 编程语言的单元测试框架&#xff0c;它是 JUnit 框架的第五个版本&#xff0c;与 JUnit 4 相比&#xff0c;JUnit 5 提供了许多改进和新特性&#xff0c;包括更好的扩展性、灵活性和对现代 Java 特性的支持。 JUnit 5 由三个主要的子模块组成&a…

开源 java android app 开发(十三)绘图定义控件、摇杆控件的制作

文章的目的为了记录使用java 进行android app 开发学习的经历。本职为嵌入式软件开发&#xff0c;公司安排开发app&#xff0c;临时学习&#xff0c;完成app的开发。开发流程和要点有些记忆模糊&#xff0c;赶紧记录&#xff0c;防止忘记。 相关链接&#xff1a; 开源 java an…

Python 库 包 sentence-transformers

sentence-transformers 是一个非常流行的 Python 库&#xff0c;专门用于将文本&#xff08;句子、段落、文档&#xff09;转换为高质量的语义向量&#xff08;嵌入&#xff09;。它基于 Transformer 架构&#xff08;如 BERT、RoBERTa、DistilBERT 等&#xff09; 的预训练模型…

《聚类算法》入门--大白话篇:像整理房间一样给数据分类

一、什么是聚类算法&#xff1f; 想象一下你的衣柜里堆满了衣服&#xff0c;但你不想一件件整理。聚类算法就像一个聪明的助手&#xff0c;它能自动帮你把衣服分成几堆&#xff1a;T恤放一堆、裤子放一堆、外套放一堆。它通过观察衣服的颜色、大小、款式这些特征&#xff0c;把…

AutoGen(五) Human-in-the-Loop(人类在环)实战与进阶:多智能体协作与Web交互全流程(附代码)

AutoGen Human-in-the-Loop&#xff08;人类在环&#xff09;实战与进阶&#xff1a;多智能体协作与Web交互全流程&#xff08;附代码&#xff09; 引言&#xff1a;AI自动化的极限与人类参与的价值 在大模型&#xff08;LLM&#xff09;驱动的AI应用开发中&#xff0c;完全自…

并查集 Union-Find

目录 引言 简单介绍 浅浅总结 算法图解 初始化 根节点查找 集合合并 连通性检查 例题 大概思路 完整代码&#xff1a; 引言 一个小小的并查集让我们在ccpc卡了那么久(还有unordered_map,如果不是忘了map自动排序这么一回事也不至于试那么多发)&#xff0c;至今仍然心有…

书籍在行列都排好序的矩阵中找数(8)0626

题目&#xff1a; 给定一个有N*M的整型矩阵matrix和一个整数K&#xff0c;matrix的每一行和每一列都是排好序的。实现一个函数&#xff0c;判断K是否在matrix中。 0 1 2 5 2 3 4 7 4 4 4 8 5 …

深度学习04 卷积神经网络CNN

卷积神经网络与人工神经网络关系与区别 概念 卷积神经网络&#xff08;Convolutional Neural Network, CNN&#xff09;是人工神经网络&#xff08;Artificial Neural Network, ANN&#xff09;的一种特殊形式&#xff0c;两者在核心思想和基础结构上存在关联&#xff0c;但在…

vue基础之组件通信(VUE3)

文章目录 前言一、父子组件通信1.父组件向子组件通信2.子组件向父组件通信3.ref父组件直接操作子组件通信。 二、跨代通信1. 跨层级通信2.事件总线通信 总结 前言 vue3的组件通信和vue2相比在语法上会有些差距&#xff0c;且vue3有的通信方式也在功能上比vue2更加完善&#xf…

【RidgeUI AI+系列】中文重复统计器

中文重复统计器 文字重复统计是一个使用文本处理工具&#xff0c; 输入文本内容并指定最小词长度后&#xff0c; 就能自动高亮显示重复的词。 本教程将会借助AI实现这个应用的开发 页面脚本编写 该工具的基础流程较为清晰&#xff1a;用户输入一段文字后&#xff0c;调用提取…

代码随想录|图论|05岛屿数量(深搜DFS)

leetcode:99. 岛屿数量 题目 题目描述&#xff1a; 给定一个由 1&#xff08;陆地&#xff09;和 0&#xff08;水&#xff09;组成的矩阵&#xff0c;你需要计算岛屿的数量。岛屿由水平方向或垂直方向上相邻的陆地连接而成&#xff0c;并且四周都是水域。你可以假设矩阵外均…

数据结构-第二节-堆栈与队列

一、概念&#xff1a; 堆栈与队列也是线性表&#xff0c;但是&#xff1a; 堆栈&#xff1a;只能在一个端进行插入删除&#xff0c;此端称为栈顶。&#xff08;特点&#xff1a;后来居上&#xff09; 队列&#xff1a;在一端进行插入&#xff08;队尾&#xff09;&#xff0…

HarmonyNext动画大全02-显式动画

HarmonyOS NEXT显式动画详解 1. 核心接口 显式动画通过animateTo接口实现&#xff0c;主要特点包括&#xff1a; 触发方式&#xff1a;需主动调用接口触发动画 参数配置 &#xff1a; animateTo({duration: 1000, // 动画时长(ms)curve: Curve.Ease, // 动画曲线delay: 200…

芯谷科技--高压降压型 DC-DC 转换器D7005

在当今电子设备日益复杂且对电源性能要求极高的背景下&#xff0c;一款高效、稳定的电源管理芯片至关重要。 D7005凭借其卓越的性能和广泛的应用适配性&#xff0c;成为众多工程师在设计电源方案时的优选。 产品简介 D7005 是一款高效、高压降压型 DC-DC 转换器&#xff0c;具…

MySQL的GTID详解

GTID&#xff08;Global Transaction Identifier&#xff0c;全局事务标识符&#xff09;是MySQL 5.6及以上版本引入的重要特性&#xff0c;用于在主从复制环境中唯一标识每个事务&#xff0c;简化复制管理、故障转移和数据一致性维护。以下从多维度详细介绍GTID&#xff1a; …

专题:2025中国游戏科技发展研究报告|附130+份报告PDF、原数据表汇总下载

原文链接&#xff1a;https://tecdat.cn/?p42756 本报告汇总解读基于艾瑞咨询《2025中国游戏科技发展白皮书》、伽马数据《2025年1-3月中国游戏产业季度报告》、嘉世咨询《2025中国单机游戏市场现状报告》等多份行业研报数据。当《黑神话&#xff1a;悟空》以虚幻引擎5复刻东…

【数据挖掘】数据挖掘综合案例—银行精准营销

要求&#xff1a; 1、根据相关的信息预测通过电话推销&#xff0c;用户是否会在银行进行存款 2、数据bank.csv&#xff0c;约4520条数据&#xff0c;17个属性值 提示&#xff1a; 17个属性&#xff0c;分别是年龄&#xff0c;工作类型&#xff0c;婚姻状况&#xff0c;受教育…

postgresql查看锁的sql语句

发现一个查看postgresql锁比较好的sql语句&#xff0c;参考链接地址如下 链接地址 查看锁等待sql witht_wait as(select a.mode,a.locktype,a.database,a.relation,a.page,a.tuple,a.classid,a.granted,a.objid,a.objsubid,a.pid,a.virtualtransaction,a.virtualxid,a.trans…

JSON 格式详解

JSON 格式详解 随着互联网的发展和各种 Web 应用程序的普及&#xff0c;数据交换已经成为了我们日常开发中的重要环节。而在各种数据交换格式中&#xff0c;JSON&#xff08;JavaScript Object Notation&#xff09;作为一种轻量级的数据交换格式&#xff0c;以其简洁、易于阅…