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

专做国外旅游的网站福州短视频seo获客

专做国外旅游的网站,福州短视频seo获客,怎样做党史网站,南宁网络公司联系方式状态 State: 在声明式UI中,以状态驱动视图更新 状态(State):指驱动视图更新的数据(被装饰器标记的变量)视图(View):基于UI描述渲染得到的用户界面 使用示例…

状态 @State:

在声明式UI中,以状态驱动视图更新

  1. 状态(State):指驱动视图更新的数据(被装饰器标记的变量)
  2. 视图(View):基于UI描述渲染得到的用户界面

使用示例:

@Entry
@Component
struct Index {// 使用状态装饰器@State message: string = 'Hello Word'build() {Column(){Text(this.message)}};
}

说明:

  • @State装饰器标记的变量初始化必须有值
  • @State支持Object、Class、string、number、boolean、enum类型以及这些类型的数组
  • 嵌套类型以及数组中的对象属性无法触发视图更新(相当于浅层监听)

父子组件数据同步 @Prop和@Link:

对比:

@Prop@Link
同步类型单向同步双向同步
允许装饰的变量类型
  • @Prop只支持string、number、boolean、enum类型
  • 父组件对象类型,子组件hi对象类型
  • 不可以是数组,any
  • 父子类型一致:string、number、boolean、enum、object、class以及他们的数组
  • 数组中元素增、删、替换会引起刷新
  • 嵌套类型以及数组中的对象属性无法触发视图更新
初始化方式不允许子组件初始化父子间传递,不允许子组件初始化

@Prop使用示例:

PS:@Prop定义的数据在子组件不能初始化

@Entry
@Component
struct Index {@State msg: string = 'Hello Word'build() {Column() {MsgModule({msg:this.msg})Button('更改文案').onClick(()=>{this.msg = 'Hello arkTs'})}}
}@Component
struct MsgModule {@Prop msg:stringbuild(){Text(this.msg).fontSize(30).fontColor('red')}
}

@Link使用示例:

PS:

  • @Link定义的数据在子组件不能初始化
  • @Link定义的数据,父组件在使用时候,去掉"this."且前边加"$"符号
@Entry
@Component
struct Index {@State msg: string = 'Hello Word'build() {Column() {MsgModule({msg: $msg})}}
}@Component
struct MsgModule {@Link msg:stringbuild(){Row(){Text(this.msg).fontSize(30).fontColor('red')Button('更改文案').onClick(()=>{this.msg = 'Hello arkTs'})}}
}

 @Provide和@Consume:(跨组件提供双向的数据同步)

  @Provide定义的数组,其他组件在使用时候直接使用@Consume定义使用,不需要在调用组件时候进行参数传递

使用示例:

@Entry
@Component
struct Index {@Provide msg: string = 'Hello Word'build() {Column() {MsgBtnModule()}}
}@Component
struct MsgBtnModule {build(){Row(){MsgModule()}}
}@Component
struct MsgModule {@Consume msg: stringbuild(){Row(){Text(this.msg).fontSize(30).fontColor('red')Button('更改文案').onClick(()=>{this.msg = 'Hello arkTs'})}}
}

@ObjectLink和@Observed:(涉及嵌套对象或数组元素为对象的场景中进行双向数据同步)

使用示例:

@Observed
class ArrInt {name: string = ""price: number = 0
}@Entry
@Component
struct Index {@State num:number = 0@State arr: ArrInt[] = [{name: '华为 Meta 50',price: 7999},{name: '华为 Meta 60',price: 8999},{name: '华为 Meta 60 pro',price: 9999},]build() {Column() {Text('涨价' + this.num.toString() + '次').fontSize(50).margin(20)ArrModule({num: $num, arr: $arr})}}
}@Component
struct ArrModule {@Link num: number@Link arr: ArrInt[]build(){Row(){List({space: 10}){ForEach(this.arr,(item: ArrInt) => {ListItem(){ArrItemModule({item:item, num: $num})}})}}}
}@Component
struct ArrItemModule {@ObjectLink item: ArrInt@Link num: numberbuild(){Column(){Text(this.item.name).fontSize(30).fontColor('red')Text(this.item.price.toString()).fontSize(30).fontColor('#000')Button('涨价').onClick(()=>{this.num += 1})}}
}

http://www.mmbaike.com/news/56179.html

相关文章:

  • 政府机关网站建设的依据引流推广平台软件
  • APP客户端网站建设网站批量查询
  • 虹口网站建设抖音seo怎么做的
  • 网站推广公司就去柚米互联网营销成功案例
  • 网站 关键词 选择今日新闻国际最新消息
  • 大连手机自适应网站建设价格淘宝推广引流方法有哪些
  • 免费网站大全app广州网络推广专员
  • 山西住房与建设部网站搜索引擎优化的概念是什么
  • 武汉营销型网站建设公司seo做的比较好的公司
  • 智能建造师报名入口官网西安seo王尘宇
  • 个人备案的网站可以做什么网站制作开发
  • 做公司网站需要备案吗昆明seo工资
  • 北京电商网站开发平台百度竞价开户3000
  • 肉山谷英雄传说新手任务登录英文网站怎么做新冠疫情最新消息今天
  • 政府系统建设网站请示营销神器
  • 老鬼seo广州seo优化公司
  • 戴尔的网站建设seo优化公司排名
  • 建自己的网站二十个优化
  • 网站建设助手chrome手机安卓版
  • 网页设计html背景颜色seo优化外包公司
  • 投诉做网站的电话百度推广公司怎么代理到的
  • 网络营销培训哪个好点安卓优化大师老版本下载
  • 哪个网站做网站好查询网站信息
  • 中国建设银行官网站招聘频道网络营销教学网站
  • 网站开发学校 优帮云宁波seo运营推广平台排名
  • ppt做视频 模板下载网站新手做seo怎么做
  • 做网站 二维码登录哪些平台可以免费打广告
  • 网站设计书怎么写石家庄百度seo排名
  • asp网站攻击广州网站快速排名优化
  • 做网站业务员如何跟客户沟通免费的郑州网络推广服务