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

OpenHarmony鸿蒙原生应用开发,ArkTS、ArkUI学习踩坑学习笔记,持续更新中。

一、AMD处理器win10系统下,DevEco Studio模拟器启动失败解决办法。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

结论:在BIOS里面将Hyper-V打开,DevEco Studio模拟器可以成功启动。

二、ArkTS自定义组件导出、引用实现。

如果在另外的文件中引用组件,需要使用export关键字导出,并在使用的页面import该自定义组件。

1.自定义组件(被导入组件)

// @ts-nocheck
@Component
struct header {build() {Flex({justifyContent:FlexAlign.Center}){Text('诸子百家').width('100%').height(70).backgroundColor(0x808080).fontColor(0x000000)}}
}
export default header

2.组合组件(引用自定义组件)

import router from '@ohos.router';
import header from './header';
let msg:String='index页面传递的消息'
@Entry
@Component
struct Index {@State message: string = '鸿蒙应用状态管理出现';@State isExpanded:boolean=false;build() {Row() {Column() {header()if (this.isExpanded){Text('鸿蒙应用状态管理消失').fontSize(60).fontWeight(FontWeight.Bold)} else {Text(this.message).fontSize(60).fontWeight(FontWeight.Bold)}Button('跳转').onClick(()=>{this.isExpanded=!this.isExpanded;router.pushUrl({url:'pages/Page',params:{src:msg}})})}.width('100%').height('100%')}.height('100%')}
}

三、@ohos.router (页面路由)实现。

1、main_pages.json配置文件配置静态路由地址,配置文件路径:src/main/resources/base/profile/main_pages.json

{"src": ["pages/Index","pages/Page","pages/Twopage"]
}

2、使用router.pushUrl方法进行应用内页面路由跳转以及传值

import router from '@ohos.router';
let msg:String='index页面传递的消息'
@Entry
@Component
struct Index {build() {Row() {Column() {Button('跳转').onClick(()=>{router.pushUrl({url:'pages/Page',params:{src:msg}})})}.width('100%').height('100%')}.height('100%')}
}

3、使用router.getParams()方法进接收路由传值

import router from '@ohos.router';@Entry
@Component
struct Page {@State message: string = '子页面2';@State src: string=router.getParams()?.['src'];build() {Row() {Column() {Text(this.message+this.src).fontSize(50).fontWeight(FontWeight.Bold);}.height('100%')}
}

…未完待续…

本文原创,原创不易,如需转载,请联系作者授权。

http://www.lryc.cn/news/263198.html

相关文章:

  • RHCE8 资料整理(十)二
  • CUDA 学习记录2
  • 探索Qt 6.3:了解基本知识点和新特性
  • 持续集成交付CICD:基于 GitLabCI 与 JenkinsCD 实现后端项目发布
  • 一些好用的VSCode扩展
  • 3dsmax渲染太慢,用云渲染农场多少钱?
  • JVM-9-Class类文件的结构
  • Redis持久化,性能管理
  • linux(centos7)离线安装mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar
  • 【lesson17】MySQL表的基本操作--表去重、聚合函数和group by
  • 面试题总结(十二)【Qt】【华清远见西安中心】
  • GPT-4V with Emotion:A Zero-shot Benchmark forMultimodal Emotion Understanding
  • CogVLM与CogAgent:开源视觉语言模型的新里程碑
  • CSS的盒子模型(重点)
  • 论文笔记:Bilinear Attention Networks
  • 2312llvm,01基本介绍
  • Spring之手写IoC
  • IDEA运行JSP启动后页面中文乱码
  • Python 自动化之收发邮件(二)
  • RHEL8_Linux_Ansible常用模块的使用
  • 2023 英特尔On技术创新大会直播 | AI 融合发展之旅
  • 【JavaWeb】往浏览器打印一个hello world
  • 技术探秘:在RISC Zero中验证FHE——由隐藏到证明:FHE验证的ZK路径(1)
  • Spring容器中scope为prototype类型Bean的回收机制
  • Python生成器(python系列25)
  • Vue项目搭建过程
  • 系统分析师(软考)知识点整理(一)
  • 2021年数维杯国际大学生数学建模D题2021年电影市场票房波动模型分析求解全过程文档及程序
  • Kubernetes 的用法和解析 -- 5
  • HTML选择题试题——附答案