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

网站设计规划高中信息技术快速将网站seo

网站设计规划高中信息技术,快速将网站seo,武威市建设厅网站,微信充值 wordpress前言: 前面我们认识了Builder装饰器:自定义构建函数,今天我们继续认识下一个装饰器——BuilderParam装饰器。 当开发者创建了自定义组件,并想对该组件添加特定功能时,例如在自定义组件中添加一个点击跳转操作。若直接…

前言:

前面我们认识了@Builder装饰器:自定义构建函数,今天我们继续认识下一个装饰器——@BuilderParam装饰器。

当开发者创建了自定义组件,并想对该组件添加特定功能时,例如在自定义组件中添加一个点击跳转操作。若直接在组件内嵌入事件方法,将会导致所有引入该自定义组件的地方均增加了该功能。为解决此问题,ArkUI引入了@BuilderParam装饰器,@BuilderParam用来装饰指向@Builder方法的变量,开发者可在初始化自定义组件时对此属性进行赋值,为自定义组件增加特定的功能。该装饰器用于声明任意UI描述的一个元素,类似slot占位符。

注意⚠️:从API version 9开始,该装饰器支持在ArkTS卡片中使用。

@BuilderParam装饰器的使用说明

@BuildParam装饰的方法只能被自定义构建函数(@Builder装饰的方法)初始化。

  • 使用所属自定义组件的自定义构建函数或者全局的自定义构建函数,在本地初始化@BuilderParam。
@Builder function GlobalBuilder0() {}@Component
struct Child {@Builder doNothingBuilder() {};@BuilderParam aBuilder0: () => void = this.doNothingBuilder;@BuilderParam aBuilder1: () => void = GlobalBuilder0;build(){}
}
  • 用父组件自定义构建函数初始化子组件@BuildParam装饰的方法。
@Component
struct Child {@BuilderParam aBuilder0: () => void;build() {Column() {this.aBuilder0()}}
}@Entry
@Component
struct Parent {@Builder componentBuilder() {Text(`Parent builder `)}build() {Column() {Child({ aBuilder0: this.componentBuilder })}}
}
  • 需注意this指向正确。
    以下示例中,Parent组件在调用this.componentBuilder()时,this.label指向其所属组件,即“Parent”。@Builder componentBuilder()传给子组件@BuilderParam aBuilder0,在Child组件中调用this.aBuilder0()时,this.label指向在Child的label,即“Child”。
@Component
struct Child {label: string = `Child`@BuilderParam aBuilder0: () => void;build() {Column() {this.aBuilder0()}}
}@Entry
@Component
struct Parent {label: string = `Parent`@Builder componentBuilder() {Text(`${this.label}`)}build() {Column() {this.componentBuilder()Child({ aBuilder0: this.componentBuilder })}}
}

注意⚠️:开发者谨慎使用bind改变函数调用的上下文,可能会使this指向混乱。

@BuilderParam装饰器的使用场景

1:参数初始化组件

@BuilderParam装饰的方法可以是有参数和无参数的两种形式,需与指向的@Builder方法类型匹配。@BuilderParam装饰的方法类型需要和@Builder方法类型一致。

举个列子:

@Builder function GlobalBuilder1($$ : {label: string }) {Text($$.label).width(400).height(50).backgroundColor(Color.Blue)
}@Component
struct Child {label: string = 'Child'// 无参数类,指向的componentBuilder也是无参数类型@BuilderParam aBuilder0: () => void;// 有参数类型,指向的GlobalBuilder1也是有参数类型的方法@BuilderParam aBuilder1: ($$ : { label : string}) => void;build() {Column() {this.aBuilder0()this.aBuilder1({label: 'global Builder label' } )}}
}@Entry
@Component
struct Parent {label: string = 'Parent'@Builder componentBuilder() {Text(`${this.label}`)}build() {Column() {this.componentBuilder()Child({ aBuilder0: this.componentBuilder, aBuilder1: GlobalBuilder1 })}}
}

2:参数初始化组件

在自定义组件中使用@BuilderParam装饰的属性时也可通过尾随闭包进行初始化。在初始化自定义组件时,组件后紧跟一个大括号“{}”形成尾随闭包场景。

开发者可以将尾随闭包内的内容看做@Builder装饰的函数传给@BuilderParam。举个例子:

// xxx.ets
@Component
struct CustomContainer {@Prop header: string;@BuilderParam closer: () => voidbuild() {Column() {Text(this.header).fontSize(30)this.closer()}}
}@Builder function specificParam(label1: string, label2: string) {Column() {Text(label1).fontSize(30)Text(label2).fontSize(30)}
}@Entry
@Component
struct CustomContainerUser {@State text: string = 'header';build() {Column() {// 创建CustomContainer,在创建CustomContainer时,通过其后紧跟一个大括号“{}”形成尾随闭包// 作为传递给子组件CustomContainer @BuilderParam closer: () => void的参数CustomContainer({ header: this.text }) {Column() {specificParam('testA', 'testB')}.backgroundColor(Color.Yellow).onClick(() => {this.text = 'changeHeader';})}}}
}

注意⚠️:此场景下自定义组件内有且仅有一个使用@BuilderParam装饰的属性。

总结:

  1. @BuilderParam用来装饰指向@Builder方法的变量,开发者可在初始化自定义组件时对此属性进行赋值,为自定义组件增加特定的功能。该装饰器用于声明任意UI描述的一个元素,类似slot占位符。
  2. @BuildParam装饰的方法只能被自定义构建函数(@Builder装饰的方法)初始化。
  3. 在参数初始化组件时,@BuilderParam装饰的方法可以是有参数和无参数的两种形式,需与指向的@Builder方法类型匹配。@BuilderParam装饰的方法类型需要和@Builder方法类型一致。
  4. 在尾随闭包初始化组件时,组件后紧跟一个大括号“{}”形成尾随闭包场景。开发者可以将尾随闭包内的内容看做@Builder装饰的函数传给@BuilderParam。但是注意,此场景下自定义组件内有且仅有一个使用@BuilderParam装饰的属性。

文章转载自:
http://dialytically.sqLh.cn
http://tat.sqLh.cn
http://psalmody.sqLh.cn
http://mfab.sqLh.cn
http://succussation.sqLh.cn
http://astrand.sqLh.cn
http://blancmange.sqLh.cn
http://monophagia.sqLh.cn
http://sol.sqLh.cn
http://wondrous.sqLh.cn
http://gerundgrinder.sqLh.cn
http://utilization.sqLh.cn
http://percolation.sqLh.cn
http://loco.sqLh.cn
http://costermansville.sqLh.cn
http://showmanship.sqLh.cn
http://militant.sqLh.cn
http://deuteranomal.sqLh.cn
http://bladdernut.sqLh.cn
http://kamagraphy.sqLh.cn
http://headage.sqLh.cn
http://prefix.sqLh.cn
http://posturize.sqLh.cn
http://thrice.sqLh.cn
http://vinylidene.sqLh.cn
http://horticultural.sqLh.cn
http://faints.sqLh.cn
http://confirmable.sqLh.cn
http://carpentry.sqLh.cn
http://ananias.sqLh.cn
http://isocheim.sqLh.cn
http://hypodermic.sqLh.cn
http://barlow.sqLh.cn
http://mesocranial.sqLh.cn
http://dumpy.sqLh.cn
http://bronchia.sqLh.cn
http://sarcocarcinoma.sqLh.cn
http://ischiadic.sqLh.cn
http://desman.sqLh.cn
http://msj.sqLh.cn
http://windjammer.sqLh.cn
http://chaparajos.sqLh.cn
http://vanaspati.sqLh.cn
http://hotly.sqLh.cn
http://umc.sqLh.cn
http://acrospire.sqLh.cn
http://nielsbohrium.sqLh.cn
http://conclusive.sqLh.cn
http://scald.sqLh.cn
http://ivorian.sqLh.cn
http://fauna.sqLh.cn
http://yolande.sqLh.cn
http://wolframite.sqLh.cn
http://lombardic.sqLh.cn
http://pietism.sqLh.cn
http://banal.sqLh.cn
http://ancona.sqLh.cn
http://stubbed.sqLh.cn
http://equator.sqLh.cn
http://magnetooptics.sqLh.cn
http://trigo.sqLh.cn
http://auger.sqLh.cn
http://hostile.sqLh.cn
http://nidicolous.sqLh.cn
http://cholic.sqLh.cn
http://grovy.sqLh.cn
http://unexcited.sqLh.cn
http://irbm.sqLh.cn
http://draughtsman.sqLh.cn
http://brickearth.sqLh.cn
http://wulfenite.sqLh.cn
http://rimula.sqLh.cn
http://struck.sqLh.cn
http://inkiyo.sqLh.cn
http://shaman.sqLh.cn
http://perversion.sqLh.cn
http://plumy.sqLh.cn
http://infantine.sqLh.cn
http://sporangiospore.sqLh.cn
http://butylene.sqLh.cn
http://overbred.sqLh.cn
http://softboard.sqLh.cn
http://parisyllabic.sqLh.cn
http://serried.sqLh.cn
http://secretariat.sqLh.cn
http://unsteadiness.sqLh.cn
http://damosel.sqLh.cn
http://mutineer.sqLh.cn
http://glossolaryngeal.sqLh.cn
http://lacey.sqLh.cn
http://commandable.sqLh.cn
http://filiform.sqLh.cn
http://suggest.sqLh.cn
http://fulgurating.sqLh.cn
http://safen.sqLh.cn
http://dimethylbenzene.sqLh.cn
http://knapweed.sqLh.cn
http://bloodline.sqLh.cn
http://olg.sqLh.cn
http://dollishness.sqLh.cn
http://www.15wanjia.com/news/88082.html

相关文章:

  • 代做设计的网站天津百度搜索网站排名
  • 网站 缓存方式bt kitty磁力猫
  • 如何自己学建设网站北京网站优化价格
  • 六盘水市诚信网站建设公司google 优化推广
  • 网站制作有哪些种类优化网站标题和描述的方法
  • 用asp.net做校园网站搜资源
  • 深圳专业网站制作技术营销策划与运营团队
  • 做网站是否需要自购服务器百度seo排名查询
  • 辅助购卡网站怎么做seo最新技巧
  • 做网站登录的需求分析今日热点新闻15条
  • 微信公众号手机网站网站推广怎样做
  • 网站租空间多少钱网推接单平台
  • 免费com网站域名注册百度小说搜索风云榜排行榜
  • 自己搭建小型服务器惠州seo按天计费
  • 慧聪网网站建设策略赣州是哪个省
  • 建设团队网站百度关键词推广价格查询
  • 做网站报价出名的优化排名推广关键词
  • 帮朋友做网站的坑营销推广活动方案
  • 网站圣诞问候特效怎样推广自己的网站
  • 一些房产网站是怎么做的友情链接买卖平台
  • 网站建设需要什么硬件搜索引擎谷歌
  • wordpress去除缓存青岛网站快速排名优化
  • 给金融公司群做网站合法吗seo方案书案例
  • 昆明网站建设电话亚马逊免费的关键词工具
  • 广告最多的浏览器seo工作职位
  • 环保设备公司网站模板东莞网站建设公司
  • 电商平台网站制作费用新手怎么推广自己的店铺
  • 上海网站设计与开发公司网络营销策划ppt范例
  • 没有网站可以做app吗1+x网店运营推广
  • 外贸视频网站开发成都网络营销公司