我正在尝试从WebView
的{{1}}获取cookie,但是在尝试从ReactNative
获取cookie时却得到“未定义”。有任何指示/建议吗?
这是我的url
代码:
ReactNative
这里相当于 render() {
return (
<WebView
source={{ uri: this.state.url }}
thirdPartyCookiesEnabled={true}
onNavigationStateChange={this._onNavigationStateChange.bind(this)}
style={{marginTop: 20}}
/>
);
}
_onNavigationStateChange(webViewState) {
let url = webViewState.url;
if (url.endsWith("/LoggedIn.htm")) {
console.log("Logged In!");
this.loadDashboardURL();
} else if (url.endsWith("/dashboard.htm")) {
console.log("Dashboard Loaded!");
console.log(url.cookies); <-- Getting UNDEFINED.
}
}
,可以正常工作:
Android