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

网站改版后 搜索不到济南城市建设集团 网站

网站改版后 搜索不到,济南城市建设集团 网站,wordpress get_the_category_list,中国进入全国紧急状态卡片跳转到应用页面(router事件) ArkTS卡片提供页面交互能力,包括卡片与卡片提供方(例如:应用)的页面跳转、卡片拉起卡片提供方进程、卡片与卡片提供方的消息传递。其中动态卡片可以使用postCardAction接口…

卡片跳转到应用页面(router事件)

ArkTS卡片提供页面交互能力,包括卡片与卡片提供方(例如:应用)的页面跳转、卡片拉起卡片提供方进程、卡片与卡片提供方的消息传递。其中动态卡片可以使用postCardAction接口、静态卡片使用FormLink实现页面交互功能。并且postCardAction和FormLink,均支持router、message和call三种类型的事件,具体使用场景如下:

  • router事件:可以使用router事件跳转到指定UIAbility,以完成点击卡片跳转至应用内页面的功能。对于非系统应用仅支持跳转到自己应用内的UIAbility。
  • call事件:可以使用call事件拉起指定UIAbility到后台,再通过UIAbility申请对应后台长时任务完成音乐播放等功能。
  • message事件:可以使用message拉起FormExtensionAbility,通过onFormEvent接口回调通知,以完成点击卡片控件后传递消息给应用的功能。

1.router事件

1.1.1概述
  • 目的:在动态卡片中,通过postCardAction接口的router能力,快速拉起卡片提供方应用的指定UIAbility(页面)。
  • 应用场景:例如相机卡片,提供拍照、录像等按钮,点击不同按钮拉起相机应用的不同页面,提升用户体验。
  • 注意:本文仅适用于动态卡片。静态卡片的跳转请参考FormLink
1.1.2 开发步骤

分为三个主要部分:

  1. 创建动态卡片(ArkTS卡片)
  2. 在卡片中布局按钮并发送router事件
  3. 在UIAbility中处理router事件,根据参数跳转不同页面

2.实现步骤

1.新建动态卡片

image-20250630212400152

2.构建卡片页面
@Entry
@Component
struct ShoppingCard {build() {Column() {Button('进入应用').onClick(() => {postCardAction(this, {action: 'router',abilityName: 'EntryAbility',params: { targetPage: 'funA' }})})Button('进入应用B').onClick(() => {postCardAction(this, {action: 'router',abilityName: 'EntryAbility',params: { targetPage: 'funB' }})}).margin(10)Button('进入应用C').onClick(() => {postCardAction(this, {action: 'router',abilityName: 'EntryAbility',params: { targetPage: 'funC' }})})}.padding(10).height('100%').width('100%').backgroundImage($r('app.media.img'))}
}

image-20250630212612314

效果如图所示

image-20250630212712827

3.UIAbility事件处理
  //1.Ability(应用的核心单元创建的回调)//want:Want 包含启动的信息 (谁启动的、如何启动的、谁携带的参数)//launchParam-启动参数onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {// 获取router事件中传递的targetPage参数   调试时查看应用启动时的参数hilog.info(DOMAIN_NUMBER, TAG, `Ability onCreate: ${JSON.stringify(want?.parameters)}`);if (want?.parameters?.params) {//检查参数是否存在//安全操作符 ?.:防止参数不存在时报错//检查条件:是否存在want.parameters.params//来源:这个params是从卡片跳转的时候传递过来的(来自postCardAction的params)// want.parameters.params 对应 postCardAction() 中 params 内容let params: Record<string, Object> = JSON.parse(want.parameters.params as string);//解析参数//为什么需要解析参数   postCardAction传入的参数是一个json字符串   JSON.parse()将字符串转化为一个JavaScript对象//转化结果 params是一个字典this.selectPage = params.targetPage as string;hilog.info(DOMAIN_NUMBER, TAG, `onCreate selectPage: ${this.selectPage}`);}}
4.根据参数路由决定跳转的页面
  onWindowStageCreate(windowStage: window.WindowStage): void {// Main window is created, set main page for this abilityhilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');let targetPage:string;switch (this.selectPage){case 'funA':targetPage = 'pages/Index';break ;case 'funB':targetPage = 'pages/Index1';break;case 'funC':targetPage = 'pages/Index2'break;default :targetPage = 'pages/Index3'}if(this.currentWindowStage === null){this.currentWindowStage = windowStage}windowStage.loadContent(targetPage);}
5.页面效果

img

6.缺陷发现

当应用已经在后台运行时点击卡片按钮:

  • 不会触发onCreateonWindowStageCreate
  • 只会触发onNewWantonForeground

所以多次点击时,selectPage 值会更新,但页面加载逻辑没有重新执行,导致显示的还是第一个加载的页面。缺少 onNewWant 实现:未处理应用已在后台时的路由更新

解决方法

/*** 当UIAbility已经在后台运行(即使没有创建新的Ability实例),并且有新的Want(意图,包含启动信息)传递过来时,系统会调用这个方法* 例如:当用户点击卡片上的不同按钮跳转到同一个UIAbility的不同功能页面时,如果UIAbility已经在后台,就会触发onNewWant而不是创建新的实例**/// 如果UIAbility已在后台运行,在收到Router事件后会触发onNewWant生命周期回调onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void {hilog.info(DOMAIN_NUMBER, TAG, `Ability onNewWant: ${JSON.stringify(want?.parameters)}`);if (want?.parameters?.params) {// want.parameters.params 对应 postCardAction() 中 params 内容let params: Record<string, Object> = JSON.parse(want.parameters.params as string);this.selectPage = params.targetPage as string;hilog.info(DOMAIN_NUMBER, TAG, `onNewWant selectPage: ${this.selectPage}`);}if (this.currentWindowStage !== null) {this.onWindowStageCreate(this.currentWindowStage);}}
7.效果展示

img


文章转载自:

http://R4Li7GYa.LLtdf.cn
http://FkJXVvNF.LLtdf.cn
http://6LleHeFB.LLtdf.cn
http://96flK2bf.LLtdf.cn
http://uWL7boXk.LLtdf.cn
http://q2l2YKWE.LLtdf.cn
http://MfEDlq5V.LLtdf.cn
http://at67MtUk.LLtdf.cn
http://6jVBTlZA.LLtdf.cn
http://GejAfNSc.LLtdf.cn
http://EEGNj79z.LLtdf.cn
http://zYPVwzhs.LLtdf.cn
http://tHZ8NDPI.LLtdf.cn
http://7ZoETKZP.LLtdf.cn
http://YmNTbibw.LLtdf.cn
http://1g0IRdDj.LLtdf.cn
http://cTKkHs2Z.LLtdf.cn
http://3BzkUJG5.LLtdf.cn
http://Efjyx4yI.LLtdf.cn
http://C25Fub9S.LLtdf.cn
http://LWHywSw9.LLtdf.cn
http://ZPOOqkzm.LLtdf.cn
http://IzNLtait.LLtdf.cn
http://2UC1WEol.LLtdf.cn
http://o2vJdL79.LLtdf.cn
http://8FphTKqD.LLtdf.cn
http://zBZnUJBq.LLtdf.cn
http://X1hlijhe.LLtdf.cn
http://cR5qVdFy.LLtdf.cn
http://r20QfaSP.LLtdf.cn
http://www.dtcms.com/wzjs/741713.html

相关文章:

  • 做电影网站服务器应用公园制作app免费吗
  • 怎么做网站受众分析推广网站优化怎么做
  • 网站上做相关链接沈阳便宜做网站的
  • 网站这么做404页面泉州seo代理商
  • 网站流量查询漳州开发区人事人才网
  • 郑州哪里做网站汉狮灵犀科技网站开发
  • 甘肃兰州旅游必去十大景点电商网站建设优化
  • android开发下载wordpress白杨seo课程
  • 怎么查网站的所有权seo技术分享免费咨询
  • 做哪种网站比较简单建设工程施工证哪个网站查询
  • 青海省住房和城乡建设网站免费的背景视频素材
  • 百度生成手机网站wordpress mu调取
  • 如何制作手机网站有没有免费的广告平台
  • 长沙网站seo技术wordpress主题2zzt
  • 企业网站怎样做可以搜索到无后台基础怎么建设网站
  • 记事本做网站怎么插图上海中学官网登录
  • 承接网站开发 app开发做网站文字居中代码
  • 2017手机网站建设方案公司网站建设亚运村
  • 响应式网站有哪些修改wordpress 表格
  • 网站建设的案例教程视频教程台州招聘网站建设
  • 自己怎样免费建设网站wordpress 禁止 字体大小
  • 怎样做好网站建设网页小游戏怎么玩
  • 网站开发哪里接到单子的mysql网站数据库
  • idc 网站源码WordPress 嵌入flash
  • 优秀购物网站建设企业咨询服务费
  • 温州如何进行网站推广网页升级紧急通知合集
  • wordpress网站不稳定郑州网站维护
  • 成都网站seo厂家建设一个高级网站的费用
  • 怎么建设自己淘宝网站国家高新技术企业证书图片
  • 如何选择坪山网站建设企业网站前端建设