HarmonyOS 使用loadUrl,服务端报错缺少参数

开发者使用该方式:this.webController.loadUrl(this.url,

[{headerKey: “nonce”,headerValue: this.header.nonce},

{headerKey: “timestamp”,headerValue: this.header.timestamp},

{headerKey: “userAccount”, headerValue: this.header.userAccount},

{headerKey: “sign”, headerValue: this.header.sign}])

HarmonyOS
2024-12-25 15:26:43
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
aquaa

可以在web组件初始化的时候先传一个空的src,然后使用onControllerAttached方法 ,以下是简单的例子:

可以直接在loadURL后追加

import web_webview from '@ohos.web.webview';
@Entry
@Component struct WebComponent
{ controller: web_webview.WebviewController = new web_webview.WebviewController()
  build() { Column() { Web({ src: '', controller: this.controller }) .javaScriptAccess(true)
    .onControllerAttached(() =>
    { this.controller.loadUrl('www.huawei.com',
      [ { headerKey: 'token', headerValue: '测试' },
        { headerKey: 'registrationId', headerValue: '0' }, ] ) }) }
  }
} 
分享
微博
QQ
微信
回复
2024-12-25 17:40:45
相关问题
HarmonyOS Push Kit 缺少服务端sdk的demo
423浏览 • 1回复 待解决
鸿蒙能开发服务端吗?
5492浏览 • 2回复 待解决
HarmonyOS POST请求,服务端拿不到数据
323浏览 • 1回复 待解决
svn客户和svn服务端版本不同。
2561浏览 • 1回复 待解决
HarmonyOS 语音识别是否是服务端能力
231浏览 • 1回复 待解决
HarmonyOS 服务端JSON字符串解析问题
712浏览 • 1回复 待解决
签名校验是否可以都在服务端执行?
1856浏览 • 1回复 待解决
HarmonyOS 集成华为一键登录 服务端demo
302浏览 • 2回复 待解决