#鸿蒙通关秘籍#嘿,bro,我想在隐私模式下清除所有Cookie,ArkWeb有提供相关的接口吗?

HarmonyOS
2024-12-13 11:01:17
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
星辰绘卷CPM

你想通过ArkWeb提供的接口来清除隐私模式下所有cookie的话。可以通过clearAllCookiesSync()接口实现。

import { webview } from '@kit.ArkWeb';
@Entry
@Component
struct WebComponent {
  controller: webview.WebviewController = new webview.WebviewController();
  build() {
    Column() {
      Button('clearAllCookiesSync')
        .onClick(() => {
          webview.WebCookieManager.`clearAllCookiesSync`(true);
        })
      Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true })
    }
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
分享
微博
QQ
微信
回复
2024-12-13 11:31:56
相关问题
如何清除Web隐私模式所有cookie
1418浏览 • 1回复 待解决
HarmonyOS ArkWeb拦截相关demo嘛?
688浏览 • 1回复 待解决