HarmonyOS 卡片中的postCardAction能用scheme直接呼到客户端某个页面吗

卡片中的postCardAction能直接用scheme直接呼到宿主某个页面么,还是需要先呼到宿主EntryAbility,然后再由EntryAbility去分发到具体页面?

例如目前的scheme是

sinaweibo://searchall?q=%23%E7%8E%8B%E4%B8%80%E5%8D%9A%E6%8D%A1%E8%B5%B7%E6%8E%89%E8%90%BD%E7%9A%84%E5%9B%BD%E6%97%97%23&luicode=10000360&lfid=widget&logfinish=1&extparam=c_type%3D36%26third_source_type%3Dchannel%26out_flag%3Dchannel
  • 1.

如何设置postCardAction,才能直接呼到宿主的这个搜索结果页面。

备注,直接按api下面的格式填写,不生效

postCardAction(this, {
  action: 'router',
  uri: item.appScheme
});
  • 1.
  • 2.
  • 3.
  • 4.
HarmonyOS
2024-12-23 15:26:36
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

支持拉起具体页面,目前postCardAction支持三种方式,分别是router、call、message。

参考代码:

/**
 * 卡片组件
 */
@Entry
@Component
struct WidgetCard {
  build() {
    Column() {
      Button('router跳转')
        .onClick(
          () => {
            postCardAction(
              this,
              {
                action: 'router',
                bundleName: 'com.example.demo',
                abilityName: 'IndexAbility',
                params: {
                  message: 'testForRouter' // 自定义要发送的message
                }
              }
            );
          }
        )

      Button('message消息')
        .onClick(
          () => {
            postCardAction(
              this,
              {
                action: 'message',
                params: {
                  message: 'testForMessage' // 自定义要发送的message
                }
              }
            );
          }
        )

      // 需要申请ohos.permission.KEEP_BACKGROUND_RUNNING权限
      Button('call启动')
        .onClick(
          () => {
            postCardAction(
              this,
              {
                action: 'call',
                bundleName: 'com.example.demo',
                abilityName: 'IndexAbility',
                params: {
                  method: 'testForCall', // 自定义调用的方法名,必填
                  message: 'testForCall' // 自定义要发送的message
                }
              }
            );
          }
        )
    }
    .width('100%')
    .height('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
分享
微博
QQ
微信
回复
2024-12-23 19:39:20
相关问题
golang redis客户端连接状态
3282浏览 • 1回复 待解决
mysql客户端怎么开启预编译?
3633浏览 • 1回复 待解决
有哪些好用免费MongoDB客户端
4345浏览 • 1回复 待解决
客户端开发无法获取code
982浏览 • 1回复 待解决
HarmonyOS 客户端向远端设备发起spp连接
1174浏览 • 1回复 待解决
HarmonyOS 客户端拖拽效果如何实现?
653浏览 • 1回复 待解决
https如何设置ca证书和客户端证书
1110浏览 • 1回复 待解决
svn客户端和svn服务版本不同。
3027浏览 • 1回复 待解决
Nginx TCP转发配置 -客户端真实IP
2890浏览 • 0回复 待解决