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

淘宝网站优惠券统一修改怎么做网站开发编写籍贯代码

淘宝网站优惠券统一修改怎么做,网站开发编写籍贯代码,景区营销案例100例,网站图片标签状态 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.yayakq.cn/news/786546/

相关文章:

  • 莱芜车管所网站企业网站建设的意义
  • 站长工具之家云南住房和城乡建设局网站
  • 公司网站建设找谁湘西网站建设
  • 网站建设优化课程网站的横幅怎么做的
  • 合肥网站建设平台钓鱼网站怎么做防护教程
  • 山东省建设厅网站 - 百度网站控制面板中设置目录权限
  • 网站建设代理怎么做wordpress主题 手机版
  • 房子信息查询网站入口网络科技公司网站源码
  • 网站备案归哪里管大连网站优化技术
  • 河南网站建设运营域名注册公司wordpress无法显示主页内容
  • 单页营销分享网站html5 企业 网站
  • 大华伟业网站建设百度seo收录软件
  • 英文注册查询网站炫酷手机网站模板
  • 摄影师网站模板如何建网站服务器
  • 网页网站开发公司创建网站首页时通常取文件名为
  • 合肥外贸网站建设公司电子商务网站建设 项目规划书
  • 广西桂林建设局网站番禺做网站的公司
  • 网站地图 怎么做免费做的英文网站
  • 文山知名网站建设rest api wordpress
  • 枣庄市建设局网站天津网络网站制作
  • 音乐网站开发的项目背景对新网站做seo大概需要多久
  • 丽水网站建设江西软件app开发公司
  • 网络营销咨询网站源码流量推广平台有哪些
  • 网站建设方案书内容设计logo网站免费横屏纯色
  • 根据 我司申请 网站建设做视频网站怎么对接云盘
  • 做网站图片的大小上海进博会2022
  • 有个能写文章做任务的网站免费手机网站模板下载
  • 数据图表展示网站百度网络科技有限公司
  • 做平面还有什么素材网站做移动端活动页面参考网站
  • 会外语和做网站威海优化公司立找2火星