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

HarmonyOS
2024-12-13 09:18:48
浏览
收藏 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 })
        }
    }
}
分享
微博
QQ
微信
回复
2024-12-13 12:18:29
相关问题
如何为网页设置单个Cookie
1347浏览 • 1回复 待解决
如何清除Web隐私模式下所有cookie
1583浏览 • 1回复 待解决
设置禁止截屏隐私模式
2988浏览 • 1回复 待解决