webview.once可以订阅一次指定类型Web事件的回调。一般在web初始化完成后可以注入。
import { webview } from '@kit.ArkWeb'
webview.once("webInited", () => {
console.log("setCookie");
webview.WebCookieManager.configCookie("https://www.example.com", 'a=b,c=d,e=f');
})
@Entry
@Component
struct WebComponent {
controller: webview.WebviewController = new webview.WebviewController();
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
}
}
} 合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
解决方案
精准高效的一站式服务支持,助力开发者商业成功