爱因斯坦大表哥
爱因斯坦大表哥
  • 发布:2024-07-14 13:46
  • 更新:2025-04-02 17:22
  • 阅读:750

纯血鸿蒙不支持plus了 plus.runtime.openURL用什么代替呢

分类:鸿蒙Next

纯血鸿蒙不支持plus了 plus.runtime.openURL用什么代替呢

2024-07-14 13:46 负责人:无 分享
已邀请:
爱因斯坦大表哥

爱因斯坦大表哥 (作者) - 123123

还有安装应用plus.runtime.install和plus.runtime.restart()重启应用

l***@163.com

l***@163.com

请问解决了?

码思泉涌

码思泉涌 - y

可以考虑开发uts插件

DCloud_UNI_yuhe

DCloud_UNI_yuhe

鸿蒙 next 的 openUrl,使用 uts 插件,可以这样写,提供一个参考:

const openURL = (url : string, errorCB ?: (result : any) => void, identity ?: string) => {
let context = getContext() as common.UIAbilityContext;

复制代码let link : string = url;  
let openLinkOptions : OpenLinkOptions = {  
    appLinkingOnly: false,  
    parameters: { demo_key: 'demo_value' }  
};  
context.openLink(link, openLinkOptions, (result) => {  
    if (errorCB) {  
        errorCB(result);  // 只有在 errorCB 存在时才调用  
    }  
}).then(() => {  
    console.info(`open link success.`);  
}).catch((err : BusinessError) => {  
    console.error(`open link failed, errCode ${JSON.stringify(err.code)}`);  
});  

}

  • lihailan

    plus.runtime.restart()重启应用 也是类似这样写?

    2024-10-30 08:59

  • DCloud_UNI_yuhe

    回复 lihailan: 对的,从鸿蒙文档里找一下对应的 api 即可

    2024-10-30 10:48

t***@163.com

t***@163.com

求解决代码

要回复问题请先登录注册

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容