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

黑河哈尔滨网站建设太原网站制作定制开发

黑河哈尔滨网站建设,太原网站制作定制开发,网站如何做3d产品,青岛官网优化一、前言 Require是校验Prop、State、Provide、BuilderParam和普通变量(无状态装饰器修饰的变量)是否需要构造传参的一个装饰器。 说明 从API version 11开始对Prop/BuilderParam进行校验。 从API version 11开始#xff0c;该装饰器支持在元服务中使用。 从API version 12开…一、前言 Require是校验Prop、State、Provide、BuilderParam和普通变量(无状态装饰器修饰的变量)是否需要构造传参的一个装饰器。 说明 从API version 11开始对Prop/BuilderParam进行校验。 从API version 11开始该装饰器支持在元服务中使用。 从API version 12开始对State/Provide/普通变量(无状态装饰器修饰的变量)进行校验。 二、概述 当Require装饰器和Prop、State、Provide、BuilderParam、普通变量(无状态装饰器修饰的变量)结合使用时在构造该自定义组件时Prop、State、Provide、BuilderParam和普通变量(无状态装饰器修饰的变量)必须在构造时传参。 三、限制条件 Require装饰器仅用于装饰struct内的Prop、State、Provide、BuilderParam和普通变量(无状态装饰器修饰的变量)。 四、使用场景 当Child组件内使用Require装饰器和Prop、State、Provide、BuilderParam和普通变量(无状态装饰器修饰的变量)结合使用时父组件TestRequire在构造Child时必须传参否则编译不通过。 TestRequire.ets代码 Entry Component struct TestRequire {State message: string Hello World;BuilderbuildTest() {Row() {Text(Hello, world).fontSize(20)}}build() {Row() {Child({regular_value: this.message,state_value: this.message,provide_value: this.message,initMessage: this.message,message: this.message,buildTest: this.buildTest,initBuildTest: this.buildTest})}.margin({ top: 30 })} }Component struct Child {BuilderbuildFunction() {Column() {Text(initBuilderParam).fontSize(20)}}Require regular_value: string Hello;Require State state_value: string Hello;Require Provide provide_value: string Hello;Require BuilderParam buildTest: () void;Require BuilderParam initBuildTest: () void this.buildFunction;Require Prop initMessage: string Hello;Require Prop message: string;build() {Column() {Text(this.initMessage).fontSize(30)Text(this.message).fontSize(30)this.initBuildTest();this.buildTest();}.width(100%).height(100%)} }效果图 使用ComponentV2修饰的自定义组件ChildPage通过父组件ParentPage进行初始化因为有Require装饰所以父组件必须进行构造赋值。 ObservedV2 class Info {Trace name: string ;Trace age: number 0; }ComponentV2 struct ChildPage {Require Param childInfo: Info new Info();Require Param state_value: string Hello;build() {Column() {Text(ChildPage childInfo name :${this.childInfo.name}).fontSize(20).fontWeight(FontWeight.Bold)Text(ChildPage childInfo age :${this.childInfo.age}).fontSize(20).fontWeight(FontWeight.Bold)Text(ChildPage state_value age :${this.state_value}).fontSize(20).fontWeight(FontWeight.Bold)}} }Entry ComponentV2 struct ParentPage {info1: Info { name: Tom, age: 25 };label1: string Hello World;Local info2: Info { name: Tom, age: 25 };Local label2: string Hello World;build() {Column() {Text(info1: ${this.info1.name} ${this.info1.age}) // Text1.fontSize(30).fontWeight(FontWeight.Bold)ChildPage({ childInfo: this.info1, state_value: this.label1}) // 调用自定义组件Line().width(100%).height(5).backgroundColor(#000000).margin(10)Text(info2: ${this.info2.name} ${this.info2.age}) // Text2.fontSize(30).fontWeight(FontWeight.Bold)ChildPage({ childInfo: this.info2, state_value: this.label2}) // 调用自定义组件Line().width(100%).height(5).backgroundColor(#000000).margin(10)Button(change info1info2).onClick(() {this.info1 { name: Cat, age: 18} // Text1不会刷新原因是没有装饰器修饰监听不到值的改变。this.info2 { name: Cat, age: 18} // Text2会刷新原因是有装饰器修饰可以监听到值的改变。this.label1 Luck; // 不会刷新原因是没有装饰器修饰监听不到值的改变。this.label2 Luck; // 会刷新原因是有装饰器修饰可以监听到值的改变。})}} }效果图 五、错误场景 Entry Component struct Index {State message: string Hello World;Builder buildTest() {Row() {Text(Hello, world).fontSize(30)}}build() {Row() {Child()}} }Component struct Child {Builder buildFunction() {Column() {Text(initBuilderParam).fontSize(30)}}// 使用Require必须构造时传参。Require regular_value: string Hello;Require State state_value: string Hello;Require Provide provide_value: string Hello;Require BuilderParam initBuildTest: () void this.buildFunction;Require Prop initMessage: string Hello;build() {Column() {Text(this.initMessage).fontSize(30)this.initBuildTest();}} }
http://www.w-s-a.com/news/440342/

相关文章:

  • 建站做网站香河住房与建设局网站
  • 如何制造一个网站域名分类网站
  • 解析视频的网站怎么做凡科网快图
  • 企业网站优化问题接单app平台有哪些
  • 怎么做网站后缀识别符号才不会变什么是电子商务网站建设
  • 中山 五金 骏域网站建设专家专门用来制作网页的软件是什么
  • 怎么做刷东西的网站数据分析软件工具有哪些
  • 官方购物网站正品交易网站域名
  • lol网站建设seo 网站太小
  • 网站建设销售职责手机网站制作软件
  • 福州百度企业网站seo如何在电脑上登录wordpress
  • 开发区全力做好网站建设网络广告营销成功案例
  • 114网站建设高并发系统架构
  • php网站打开一片空白wordpress中文广告插件下载
  • 怎样建自己的网站免费的百度关键词排名点击
  • 医院网站建设的特点怎么查看网站百度快照
  • 网站 如何备案一般网站开发公司
  • 做网站的公司 贵阳郑州新像素ui设计培训收费
  • 温州网站建设公司电话给个免费的网址
  • 个人做电子商务网站备案软考高级
  • 淘宝客需要自己做网站吗四川遂宁做网站的公司
  • 编写网站策划书缘魁上海网站建设
  • 梧州外贸网站推广设计wordpress 上传 七牛
  • 增加网站备案千灯做网站
  • 深圳做网站的公php做简易网站
  • 徐州哪家做网站好商业空间设计效果图
  • 重庆建网站cqiezscom大学毕业做网站插画师好吗
  • 在门户网站做产品seo怎么样做网站管理员
  • 动画做视频在线观看网站字体安装+wordpress
  • vs2015网站开发做珠宝建个网站推广怎么样