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

沈阳网站制作策划域名备案网站建设方案书

沈阳网站制作策划,域名备案网站建设方案书,不用vip的免费追剧软件,网站后台管理系统是用什么做的1.组件重用样式 如果每个组件的样式都需要单独设置#xff0c;在开发过程中会出现大量代码在进行重复样式设置#xff0c;虽然可以复制粘贴#xff0c;但为了代码简洁性和后续方便维护#xff0c;可以采用公共样式进行复用的装饰器Styles。 Styles装饰器可以将多条样式设置…1.组件重用样式 如果每个组件的样式都需要单独设置在开发过程中会出现大量代码在进行重复样式设置虽然可以复制粘贴但为了代码简洁性和后续方便维护可以采用公共样式进行复用的装饰器Styles。 Styles装饰器可以将多条样式设置提炼成一个方法直接在组件声明的位置调用。通过Styles装饰器可以快速定义并复用自定义样式。用于快速定义并复用自定义样式。 当前Styles仅支持[通用属性]和[通用事件]。  styles方法不支持参数 Styles可以定义在组件内或全局在全局定义时需在方法名前面添加function关键字组件内定义时则不需要添加function关键字。 注意: 组件内Styles的优先级高于全局Styles. 框架优先找当前组件内的Styles如果找不到则会全局查找。 Entry //入口 Component struct PageB_build_param {State message: string Hello World //State 数据改变了也刷新的标签State username: string State password: string State widths:number 90build() {Row() {Column() {text({ title: 用户, valueStr:this.username, cb: (value:string) {this.usernamevalue} })text({ title:密码,valueStr:this.password,cb:(value:string){this.passwordvalue} })Divider().margin(10)Row() {Button(登录).fontSize(16).myprivateStyle().margin({ right: 10, left: 10 }).onClick(this.login.bind(this))Button(重置).fontSize(16).myprivateStyle().margin({ left: 10, right: 10 }).onClick(this.reset.bind(this))}}.width(100%).height(50%)}.height(100%).width(100%)}Styles//提取共有的属性 在struct内myprivateStyle(){.width(this.widths).height(50)}//登录login() {console.log(this.username----this.password)}reset() {this.username this.password this.widths180} } Styles//全局样式 提取 function Mystyle(){.margin(10).padding(10).width(80).height(50).backgroundColor(#333333) }Builder //全局自定义构件函数 function text($$: { title: string,valueStr: string,cb: (value: string) void }) {Row() {Text($$.title).Mystyle().fontSize(16).fontColor(Color.White).textAlign(TextAlign.Center).border({width: 3,color: Color.Blue}).borderRadius(10).fontWeight(FontWeight.Bold)TextInput({ text: $$.valueStr }).width(200).height(50).fontSize(16).onChange((value: string) {$$.cb(value)})}.alignItems(VerticalAlign.Center)} 2.扩展组件样式 Extend(UIcomponentName) function functionName { ... } ·和Styles不同Extend仅支持定义在全局不支持在组件内部定义。 ·和Styles不同Extend支持封装指定的组件的私有属性和私有事件和预定义相同组件的Extend的方法。·和Styles不同Extend装饰的方法支持参数开发者可以在调用时传递参数调用遵循TS方法传值调用·Extend装饰的方法的参数可以为function作为Event事件的句柄。 Extend的参数可以为状态变量当状态变量改变时UI可以正常的被刷新渲染。 Extend(Text)//全局对组件-Text进行扩展 function MyTextExtend(text:string){.margin(10).padding(10).width(80).height(50).backgroundColor(text用户? #666666 : #333333).fontSize(16).fontColor(Color.White).textAlign(TextAlign.Center).border({width: 3,color: Color.Blue}).borderRadius(10).fontWeight(FontWeight.Bold) }Extend(TextInput)//对组件textinput进行扩展 function myTextInput(cb:(value :string ) void){.width(200).height(50).fontSize(16).onChange((value: string) {cb(value)}) }Builder //全局自定义构件函数 function text($$: { title: string,valueStr: string,cb: (value: string) void }) {Row() {Text($$.title).MyTextExtend($$.title)TextInput({ text: $$.valueStr }).myTextInput($$.cb)}.alignItems(VerticalAlign.Center) } 3.多态样式 stateStyles是属性方法可以根据UI内部状态来设置样式类似于css伪类但语法不同。ArkUI提供以 下四种状态: focused:获焦态。 normal: 正常态。 pressed: 按压态。 disabled: 不可用态。 Extend(TextInput)//对组件textinput进行扩展 function myTextInput(cb:(value :string ) void){.width(200).height(50).fontSize(16).stateStyles({normal:normalStyle,pressed:pressStyle,focused:foucsStyle}).onChange((value: string) {cb(value)}) } Styles function pressStyle(){.backgroundColor(Color.White) } Styles function foucsStyle(){.backgroundColor(Color.Red) } Styles function normalStyle(){.backgroundColor(Color.Green) }4.循环渲染 ForEach( arr: Array, itemGenerator: (item: any, index?: number) void, keyGenerator?: (item: any index?: number): string string ) 在ForEach循环渲染过程中系统会为每个数组元素生成一个唯一且持久的键值 用于标识对应的组件。当这个键值变化时ArkUI框架将视为该数组元素已被替换或修改,并会基于新的键值创建一个新的组件。 ForEach提供了一个名为keyGenerator的参数,这是一个函数,开发者可以通过它自定义键值的生成规则。如果开发者没有定义keyGenerator函数则ArkUI框架会使用默认的键值生成函数即(item: any, index: number) { return index _ JSON.stringify(item); }。 Entry Component struct PageForEach {State list: string [] [Hello World, hello harmonyos, hello my]State list1: Object [] [{ id: 1, name: 房子 }, { id: 2, name: 车子 }, { id: 3, name: 票子 }]build() {Row() {Column() {ForEach(this.list, (item: string) {Text(item).fontSize(26)})ForEach(this.list1, (item1: Object) {Text(item1[name]).fontSize(26)},itemJSON.stringify(item))//用这个去作为唯一的key// List组件配合 ForEach超出屏幕可以滚动List(){ForEach(this.list1,(item1:Object){ListItem(){Text(item1[name]).fontSize(26).margin(10)}},itemJSON.stringify(item))}.height(60).divider({startMargin:10,endMargin:10,strokeWidth:1,color:Color.Green})Button(切换).onClick((){this.list1[1][name]银山this.list1.splice(0,1,{id:1,name:金山})})}.width(100%)}.height(100%)} }
http://www.dnsts.com.cn/news/8803.html

相关文章:

  • 做问卷调查赚钱的网站装修设计师网站
  • 关于网站建设的大学网站后台是怎么做出来的
  • 国外网站的分析工具有哪些表情制作在线生成器
  • wordpress收费主题破解版东莞百度seo排名
  • 网站建设实训的意义检查网站是否做网站地图
  • 怎么免费做网站推广科技有限公司简介
  • 什么是网站和网页广州市网站建设科技公司
  • 高端网站开发建设合肥网页定制
  • 3322做网站国内flex做的网站
  • 网站建设公司需要什么网络营销渠道的功能包括
  • 响应式网站的几种尺寸重启wordpress
  • 全新升级网站宁波网站建设哪里好
  • ai设计网站东莞横沥电子厂
  • 企业网站托管有必要吗网页制作软件手机版
  • 网站美工设计流程求婚策划公司
  • 和男朋友都是第一次做网站enfold wordpress主题
  • 江苏扬州建设局网站开源商城cms
  • 运城 网站制作企业手机网站设计
  • 可以做的电影网站优化方案2022
  • 重庆市建设政务中心网站重新wordpress默认
  • 天津网站搜索优化阳江房产网签数据
  • wordpress清空登录金坛网站优化
  • wordpress建站入门手机 写wordpress
  • 如何建立公司网站模块wordpress自动备份
  • 婚纱网站源码信息网站推广
  • 网网站站建建设设wordpress营业中
  • 重庆seo网站管理企业顺德网站建设
  • 自己做网站还是开淘宝wordpress 緩慢
  • 微网站免费制作一个网址多少钱
  • 腾讯云阻止网站访问自建购物网站