cuốn sách gpt4 ai đã làm

ios - 如何修复“WKWebViewManager.evaluateJavaScript 不是函数”

In lại Tác giả: Walker 123 更新时间:2023-11-29 05:51:30 hai mươi bốn 4
mua khóa gpt4 Nike

我正在开发 Expo 的 React Native 应用程序。我将项目弹出到 ExpoKit 并添加了 react-native-wkwebview-reborn。我遇到了这个库的一些问题,因为总是出现这个错误:

nhập mô tả hình ảnh ở đây

这是我的代码:ContentWebView.ios.js

kết xuất() {
trở lại (

<>
ref={WEBVIEW_REF}
sendCookies={true}
style={styles.webview}
source={{uri: this.props.url}}
allowsLinkPreview={false}
onMessage={(e) => this._handleMessage(e)}
onNavigationStateChange={(e) => this._onNavigationStateChange(e)}
/>

这是我的应用程序崩溃的地方:

_onNavigationStateChange(e) {
this.refs[WEBVIEW_REF].evaluateJavaScript('window.postMessage({cookies: document.cookie}); clearInterval(window.myCartInterval); window.myCartInterval = setInterval(function(){window.postMessage({cookies: document.cookie});},5000);');
}

如果您有任何想法,那将会非常有用!谢谢

câu trả lời hay nhất

你可以尝试更改代码吗?

试试这个方法。

   <>
ref={WEBVIEW_REF => {this.webview = WEBVIEW_REF;}}
sendCookies={true}
style={styles.webview}
source={{uri: this.props.url}}
allowsLinkPreview={false}
onMessage={(e) => this._handleMessage(e)}
onNavigationStateChange={(e) => this._onNavigationStateChange(e)}
/>
...
_onNavigationStateChange(e) {
this.webview.evaluateJavaScript('window.postMessage(e)');
}

关于ios - 如何修复“WKWebViewManager.evaluateJavaScript 不是函数”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55627246/

hai mươi bốn 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress