【发布时间】:2019-10-22 01:55:02
【问题描述】:
我正在尝试检索用户输入的邮政编码,该邮政编码已添加到 web 视图中的 cookie 中。我如何得到它?
我试过 react-native-cookies 得到一个空对象。
import CookieManager from 'react-native-cookies';
componentWillMount() {
CookieManager.get('https://www.example.com')
.then((res) => {
console.log('CookieManager.get from webkit-view =>', res);
});
}
}
<WebView
style={styles.webview}
source={{ uri: 'https://www.example.com' }}
injectedJavaScript={INJECTED_JAVASCRIPT}
mixedContentMode="compatibility"
javaScriptEnabled
domStorageEnabled
thirdPartyCookiesEnabled
sharedCookiesEnabled
originWhitelist={['*']}
useWebKit
/>
我正在 iOS 模拟器中试用。安卓很好用。 我看到 https://github.com/react-native-community/react-native-webview/pull/175 已合并,但不知道如何使用它来获取用户设置的 cookie。
【问题讨论】:
-
您使用的是
react-native-webview版本>= 5.7.0 吗? -
我使用的是最新版本。 “react-native-cookies”:“3.3.0”,“react-native-webview”:“^5.11.0”
标签: react-native react-native-ios react-native-webview react-native-cookies