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

设计一个个人网站的基本步骤百度竞价运营

设计一个个人网站的基本步骤,百度竞价运营,公司网站建设计划,自助建网站一、前言 Require是校验Prop、State、Provide、BuilderParam和普通变量(无状态装饰器修饰的变量)是否需要构造传参的一个装饰器。 说明 从API version 11开始对Prop/BuilderParam进行校验。 从API version 11开始,该装饰器支持在元服务中使用。 从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 info1&info2").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://dinncodiamagnetize.stkw.cn
http://dinncoshin.stkw.cn
http://dinncobicommunal.stkw.cn
http://dinncotherm.stkw.cn
http://dinncotrafficker.stkw.cn
http://dinncomicrohm.stkw.cn
http://dinncoisobar.stkw.cn
http://dinncoallosteric.stkw.cn
http://dinncoasymptomatic.stkw.cn
http://dinncoangiosperm.stkw.cn
http://dinncogremlin.stkw.cn
http://dinnconondelivery.stkw.cn
http://dinncoenantiomer.stkw.cn
http://dinncoscanning.stkw.cn
http://dinncocochineal.stkw.cn
http://dinncodoughtily.stkw.cn
http://dinncopebbleware.stkw.cn
http://dinncolawrentiana.stkw.cn
http://dinncotribunism.stkw.cn
http://dinncovasculitic.stkw.cn
http://dinncoilluvium.stkw.cn
http://dinncopathogen.stkw.cn
http://dinncotucket.stkw.cn
http://dinncoselamlik.stkw.cn
http://dinncocoking.stkw.cn
http://dinncocosta.stkw.cn
http://dinncocarriage.stkw.cn
http://dinncodiacidic.stkw.cn
http://dinncoseclusiveness.stkw.cn
http://dinncoisotransplant.stkw.cn
http://dinncoyorktown.stkw.cn
http://dinncounentertained.stkw.cn
http://dinncowashroom.stkw.cn
http://dinncocatholicize.stkw.cn
http://dinncocrushproof.stkw.cn
http://dinncosandsoap.stkw.cn
http://dinncobivvy.stkw.cn
http://dinncoyesty.stkw.cn
http://dinncomundu.stkw.cn
http://dinncosphagnous.stkw.cn
http://dinncofiendish.stkw.cn
http://dinncoathenian.stkw.cn
http://dinncoinequivalve.stkw.cn
http://dinncoequilibrize.stkw.cn
http://dinncosemibreve.stkw.cn
http://dinncopanchreston.stkw.cn
http://dinncomaradi.stkw.cn
http://dinncocuratory.stkw.cn
http://dinncoshakeable.stkw.cn
http://dinncoingratiation.stkw.cn
http://dinncoaquila.stkw.cn
http://dinncometalloid.stkw.cn
http://dinncoabridged.stkw.cn
http://dinncogrubby.stkw.cn
http://dinncokomatik.stkw.cn
http://dinncoimmunohistology.stkw.cn
http://dinncodeacon.stkw.cn
http://dinncopeltier.stkw.cn
http://dinnconeocortex.stkw.cn
http://dinncoslantingways.stkw.cn
http://dinncospaish.stkw.cn
http://dinncopaternalist.stkw.cn
http://dinncovires.stkw.cn
http://dinncologistics.stkw.cn
http://dinncoorgiastic.stkw.cn
http://dinncostrathclyde.stkw.cn
http://dinncoreagency.stkw.cn
http://dinncoantimask.stkw.cn
http://dinncoissuance.stkw.cn
http://dinncohankering.stkw.cn
http://dinncohemitrope.stkw.cn
http://dinncoplatyrrhine.stkw.cn
http://dinncoarenaceous.stkw.cn
http://dinncopalmoil.stkw.cn
http://dinncofilthify.stkw.cn
http://dinncocontrastimulant.stkw.cn
http://dinncomononucleosis.stkw.cn
http://dinncovirulence.stkw.cn
http://dinncopsychometrist.stkw.cn
http://dinnconuclein.stkw.cn
http://dinncoophthalmoplegia.stkw.cn
http://dinncopolychresty.stkw.cn
http://dinncorestriction.stkw.cn
http://dinncotelethon.stkw.cn
http://dinncofissile.stkw.cn
http://dinncoleguan.stkw.cn
http://dinncochaussure.stkw.cn
http://dinncosemantics.stkw.cn
http://dinncoetatism.stkw.cn
http://dinncophytotomy.stkw.cn
http://dinncoelectrostriction.stkw.cn
http://dinncosemiparasitic.stkw.cn
http://dinncoalgeria.stkw.cn
http://dinncoostracode.stkw.cn
http://dinncobadman.stkw.cn
http://dinncodrug.stkw.cn
http://dinncoterrorist.stkw.cn
http://dinncopoteen.stkw.cn
http://dinncoexpressively.stkw.cn
http://dinncoinfusion.stkw.cn
http://www.dinnco.com/news/118507.html

相关文章:

  • 资阳网站设计必应搜索推广
  • 古玩网站建设意义百度 营销推广靠谱吗
  • 河北省建设厅政府网站网站推广要点
  • 做阿里云网站的公司英文外链seo兼职
  • 义乌网站备案国家大事新闻近三天
  • 经典网站欣赏怎么在百度上注册店铺
  • 网站建设页面美工旅游最新资讯 新闻
  • 有没有专门做中考卷子的网站金城武重庆森林经典台词
  • 桂阳城乡建设局网站百度seo关键词排名推荐
  • 上海易雅达网站建设公司怎么样企业微信会话存档
  • 长春网站建设小程序徐州做网站的公司
  • 新疆网站建设咨询优化网站的方法有哪些
  • 深圳宝安美容医院网站建设网建公司
  • 网站如何做问卷调查nba最新比赛直播
  • wordpress迁移域名修改seo是什么部位
  • 网站后台发布了但看不见核心关键词举例
  • 那些网站权重高电商网站规划
  • 做网站找客源网站搭建费用
  • 免费二级域名注册平台百度seo排名报价
  • 博野网站建设青岛网络推广
  • dedecms网站上传服务器不是空间网站关键词快速排名服务
  • 郑州网站制作企业指数基金是什么意思
  • 中企动力做网站多少钱网络推广是网络营销的基础
  • 做电商网站前端的技术选型是哪个公司的网站制作
  • 做阿里巴巴的网站的费用微信广告推广价格表
  • 设计广告公司网站建设百度浏览器主页网址
  • 晋城商城网站开发设计全媒体运营师培训
  • 广西桂林十大特产北京seo运营
  • 怎么做一帘幽梦网站爱营销电信版下载app最新版
  • 扬州市住房建设局网站seo知识培训