卡片点击跳转主应用时,主应用如何接收来自卡片的数据?

卡片点击跳转主应用时,主应用如何接收来自卡片的数据?

HarmonyOS
2024-07-21 12:22:08
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
jmzgh
//卡片中代码
Text("跳转主应用")
  .onClick(()=>{
    postCardAction(this,{
      action:"router",
      bundleName: 'com.lingmou.myapplication',
      abilityName: 'EntryAbility',
      params: {
        message: 'testForRouter' // 自定义要发送的message
      }
    })
  })
  //在主应用EntryAbility中的onCreate接收参数,参数为parameters下的params。是个string类型的,需要自己转为json。
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
  console.log("==========want:"+JSON.stringify(want))
}
分享
微博
QQ
微信
回复
2024-07-21 18:42:37
提问
该提问已有0人参与 ,帮助了0人