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

门户网站制作方法四川成都房产网

门户网站制作方法,四川成都房产网,大学生网站设计大作业,深圳市专业网站建设1、HarmonyOS 怎么用一个变量观察其他很多个变量的变化? 有一个提交按钮的颜色,需要很多个值非空才变为红色,否则变为灰色,可不可以用一个变量统一观察这很多个值,去判断按钮该显示什么颜色,比如Button().…
1、HarmonyOS 怎么用一个变量观察其他很多个变量的变化?

有一个提交按钮的颜色,需要很多个值非空才变为红色,否则变为灰色,可不可以用一个变量统一观察这很多个值,去判断按钮该显示什么颜色,比如Button().backgroundColor(this.color),this.color的值取决于很多个输入框的值

想将子组件与父组件的变量绑定起来,实现其中一个变量改变,对应的变量也做同步的改变,可以做如下操作:将子组件的变量需要用@Link修饰,且不能初始化将父组件的变量需要用@State修饰。传值的时候使用$符号修饰。

import Prompt from '@system.prompt'
@Entry
@Component
struct Index {//父组件的变量需要用@State修饰@State inputUserName:string ='张三'@State inputUserPsw:string ='张三'build() {Row() {Column() {Text(this.inputUserName).fontSize(20)// 使用子组件传值的时候用$传递LoginInput({hint:'请输入账号',inputVale:$inputUserName})LoginInput({hint:'请输入账号',inputVale:$inputUserPsw})}.width('100%')}.height('100%')}}
@Component
struct LoginInput {private hint: string = '请输入账号密码';//子组件的变量需要用@Link修饰,且不能初始化@Link inputVale: string;build() {TextInput({placeholder:this.hint,text:this.inputVale}).onChange((value)=>{this.inputVale= value;Prompt.showToast({message:value})})}
}
2、HarmonyOS 动画过程中UI残留?

等长没有异常。只有3->2出现 出现后点击屏幕任意点 刷新消失

参考以下示例通过onChange实现切换时自定义tabBar和TabContent的联动:

// xxx.ets
@Entry
@Component
struct TabsExample {@State fontColor: string = '#182431'@State selectedFontColor: string = '#007DFF'@State currentIndex: number = 0private controller: TabsController = new TabsController()@Builder tabBuilder(index: number, name: string) {Column() {Text(name).fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor).fontSize(16).fontWeight(this.currentIndex === index ? 500 : 400).lineHeight(22).margin({ top: 17, bottom: 7 })Divider().strokeWidth(2).color('#007DFF').opacity(this.currentIndex === index ? 1 : 0)}.width('100%')}build() {Column() {Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) {TabContent() {Column().width('100%').height('100%').backgroundColor('#00CB87')}.tabBar(this.tabBuilder(0, 'green'))TabContent() {Column().width('100%').height('100%').backgroundColor('#007DFF')}.tabBar(this.tabBuilder(1, 'blue'))TabContent() {Column().width('100%').height('100%').backgroundColor('#FFBF00')}.tabBar(this.tabBuilder(2, 'yellow'))TabContent() {Column().width('100%').height('100%').backgroundColor('#E67C92')}.tabBar(this.tabBuilder(3, 'pink'))}.vertical(false).barMode(BarMode.Fixed).barWidth(360).barHeight(56).animationDuration(400).onChange((index: number) => {this.currentIndex = index}).width(360).height(296).margin({ top: 52 }).backgroundColor('#F1F3F5')}.width('100%')}
}
3、HarmonyOS Tabs 控件 底部显示不全?

Tabs 控件 底部显示不全 TabContent() 中的页面,底部显示不全

Scroll(this.scroller)的高度设百分比,和上面的相加为100%即可,参考DEMO:

@Entry
@Component
struct newPage {@State fontColor: string = '#182431'@State selectedFontColor: string = '#007DFF'@State currentIndex: number = 0private controller: TabsController = new TabsController()scroller: Scroller = new Scroller()private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]@BuildertabBuilder(index: number, name: string) {Column() {Text(name).fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor).fontSize(16).fontWeight(this.currentIndex === index ? 500 : 400).lineHeight(22).margin({ top: 17, bottom: 7 })Divider().strokeWidth(2).color('#007DFF').opacity(this.currentIndex === index ? 1 : 0)}.width('100%')}build() {Column() {Tabs({ barPosition: BarPosition.End, index: this.currentIndex, controller: this.controller }) {TabContent() {Column() {Row() {Text('首页').align(Alignment.Center)}.justifyContent(FlexAlign.Center).height('10%') //上面的设10%.width('100%').padding({ left: 10, right: 10 }).backgroundColor(Color.Green)Scroll(this.scroller) {Column() {ForEach(this.arr, (item: number) => {Text(item.toString()).width('90%').height(150).backgroundColor(0xFFFFFF).borderRadius(15).fontSize(16).textAlign(TextAlign.Center).margin({ top: 10 })}, (item: string) => item)}.width('100%')}.height('90%')  //Scroll设90%.scrollable(ScrollDirection.Vertical) // 滚动方向纵向.friction(0.6).edgeEffect(EdgeEffect.None)}}.tabBar(this.tabBuilder(0, 'green'))TabContent() {Column().width('100%').height('100%').backgroundColor('#007DFF')}.tabBar(this.tabBuilder(1, 'blue'))}.vertical(false).barMode(BarMode.Fixed).barWidth(360).barHeight(56).animationDuration(400).onChange((index: number) => {this.currentIndex = index}).width('100%').height('100%').backgroundColor('#F1F3F5')}.width('100%').height('100%')}
}
4、HarmonyOS 被@ObservedV2和@Trace标记的类及字段,使用JSON.stringify之后字段名称都加上了“__ob_”开头的字段?

使用JSON.stringify序列化之后字段名称都改变了,导致无法反序列化回来。

关于序列化后会有__ob_前缀的问题,可以在序列前替换掉__ob_前缀,demo如下

import  { plainToClass } from "class-transformer";
@ObservedV2
class Son {@Trace age: number = 100;
}
class Father {son: Son = new Son();
}
@Entry
@Component
struct Index {father: Father = new Father();aboutToAppear(): void {let a = JSON.stringify(this.father);let b: Father = plainToClass(Father,this.father);//{"son":{"__ob_age":100}}替换成{"son":{"age":100}}console.log(JSON.stringify(convertKeysToCamelCase(this.father)))}build() {Column() {// 当点击改变age时,Text组件会刷新Text(`${this.father.son.age}`).onClick(() => {this.father.son.age++;})}}
}// utils.ets
export function underscoreToCamelCase(underscoreString:string):string {// 捕获__ob_替换成''return underscoreString.replace(/(__ob_)/g, (match:string, letter:string):string=> {console.log(letter)return '';});
}
export function convertKeysToCamelCase(obj:ESObject):ESObject {if (obj && typeof obj === 'object') {const newObj:ESObject = {};Object.keys(obj).forEach((key)=> {if (obj.hasOwnProperty(key)) {const newKey = underscoreToCamelCase(key);newObj[newKey] = convertKeysToCamelCase(obj[key]);}})return newObj;} else {return obj;}
}
5、HarmonyOS 文字背景局部拉伸问题?
  1. backgroundImageResizable设置无作用,Image设置resizable是可以的
  2. 如何让同级控件宽度自适应文字宽度

获取文本长度的方式参考文档,让backgroundImageSize改为文字的宽度:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-measure-V5#ZH-CN_TOPIC_0000001884917586__measuremeasuretext

实现方式demo:

import measure from '@ohos.measure'@Entry
@Component
struct IR240513200608052 {@State message: string = 'Hello World啊哈哈哈哈哈哈哈哈哈';@State textWidth: number = measure.measureText({ textContent: this.message })build() {Column() {Text(this.message).backgroundImage($r('app.media.startIcon')).backgroundImageResizable({slice: {top: 3,left: 3,bottom: 3,right: 3}}).backgroundImageSize({ width: this.textWidth })}.height('100%').width('100%')}
}

文章转载自:

http://0006i8GB.Lpcpb.cn
http://B100uTAZ.Lpcpb.cn
http://wAXFmXjx.Lpcpb.cn
http://pjBXi1Lh.Lpcpb.cn
http://kHbAsF6o.Lpcpb.cn
http://3pSaCDC5.Lpcpb.cn
http://XPtLt0nk.Lpcpb.cn
http://V93Szkbg.Lpcpb.cn
http://N57U64oC.Lpcpb.cn
http://2Gz93hDw.Lpcpb.cn
http://sjRH2nMa.Lpcpb.cn
http://oN9s6omq.Lpcpb.cn
http://777ZQuGO.Lpcpb.cn
http://pkibwC4D.Lpcpb.cn
http://cBJzyJQ4.Lpcpb.cn
http://KdEM26c5.Lpcpb.cn
http://utkOxKOg.Lpcpb.cn
http://KTgnYbCf.Lpcpb.cn
http://nWxR9MIA.Lpcpb.cn
http://1GfK2eDT.Lpcpb.cn
http://OmY1jvW7.Lpcpb.cn
http://fFDkFOzJ.Lpcpb.cn
http://sK89B0HG.Lpcpb.cn
http://LhDSQPnA.Lpcpb.cn
http://5bHYz3Gp.Lpcpb.cn
http://sst9eSpd.Lpcpb.cn
http://GWaoFXCR.Lpcpb.cn
http://NcXbsbIm.Lpcpb.cn
http://Bkc2DX9V.Lpcpb.cn
http://N4izneip.Lpcpb.cn
http://www.dtcms.com/wzjs/684593.html

相关文章:

  • 长尾关键词挖掘爱站网东莞响应式网站实力乐云seo
  • 仙居建设局网站企业网站建设有什么好
  • 推广网站建设语句英国帮人做设计作业网站
  • 成都网站建设龙兵科技高德地图能否上传vr全景图片
  • 微网站开发项目合作协议广告艺术设计学什么
  • 西安俄语网站建设网站免费建站方法
  • 乐清网站的建设如何做购物券网站
  • 建站行业新闻企业网站注册官网
  • 江宁招网站建设58虚拟主机 安装wordpress
  • asp 网站发布器网站效果图确认表
  • 代做网站灰色关键词长沙网站建立公司
  • 建筑网站大全免费wordpress vatage
  • 北京网站建设制作哪家公司好WordPress中英文旅游模板
  • 网站建设的目的做影视网站能赚到钱吗
  • 功能多的免费网站建设怎么一键打开两个wordpress
  • 广州上市网站建设的公司网络科技网站排名
  • 关于做一动物网站的界面个建视频网站
  • 手机版网站模板下载免费源码html网站
  • 万网的怎么做网站地图网站推广策划评估指标有哪些
  • 网站开发公司可行报告网站开发完了备案
  • 芜湖企业做网站网站怎么挂服务器
  • 四川省城乡建设部网站首页电子采购平台系统
  • 沈阳做网站公司哪家好菜鸟做网站
  • 澄海建网站中国建设银行官网站电脑版
  • 数据网站建设网站框架结构图
  • 电子商务网站建设实验心得搭建网站平台
  • 网站备案名字填写海口网站建设方案咨询
  • 东莞做营销型网站的湖南营销网站建设
  • 有什么网站开发软件怎么寻找做有意做网站的客户
  • 适合做网站服务器的主机网站网页设计0基础学