中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
cookie的读、写和删除操作
微信扫码分享
operationMethod(): void { try { if (this.buttonType === CookieOperation.GET_COOKIE) { let originCookie = web_webview.WebCookieManager.fetchCookieSync(CommonConstants.USER_CENTER_URL); showDialog(originCookie); } else if (this.buttonType === CookieOperation.SET_COOKIE) { web_webview.WebCookieManager.configCookieSync(CommonConstants.USER_ABOUT_URL, 'info=测试cookie写入'); showDialog($r('app.string.write_success')); } else if (this.buttonType === CookieOperation.DELETE_COOKIE) { web_webview.WebCookieManager.clearAllCookiesSync(); let deleteMessage = $r('app.string.delete_success'); showDialog(deleteMessage); } else { router.pushUrl({ url: CommonConstants.PAGE_VERIFY }) } } catch (error) { showDialog('Operation failed.'+JSON.stringify(error)); } }