#鸿蒙通关秘籍#就是啊,我现在需要在隐私模式下设置指定URL的单个Cookie值,ArkWeb可以基于什么API来实现?

HarmonyOS
2024-12-13 09:18:48
1370浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
SMTP寒山石径

可以看看这个,allowGeolocation()接口设置隐私模式下的Web组件使用指定来源使用地理位置。

import { webview } from '@kit.ArkWeb';
@Entry
@Component
struct WebComponent {
    controller: webview.WebviewController = new webview.WebviewController();
    origin: string = "file:///";
    build() {
        Column() {
            Button('allowGeolocation')
            .onClick(() => {
                webview.GeolocationPermissions.`allowGeolocation`(this.origin, 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.
  • 16.
分享
微博
QQ
微信
回复
2024-12-13 12:18:29
相关问题
如何为网页设置单个Cookie
1182浏览 • 1回复 待解决
如何清除Web隐私模式下所有cookie
1379浏览 • 1回复 待解决
设置禁止截屏隐私模式
2557浏览 • 1回复 待解决