我有一个React Native App,它使用WebView从资产中呈现HTML页面.该页面有一些javascript进行一些处理.问题是我无法console.log从Web视图中看到这些语句.我尝试过Chrome 远程调试WebViews
这是代码的样子.请注意,对于Android,我试图提供一些本机道具来启用调试.
import React from 'react';
import Expo from 'expo';
import { WebView } from 'react-native';
export default class App extends React.Component {
render() {
const htmlURL = Expo.Asset.fromModule(require('./assets/index.html')).uri;
return (
<WebView nativeConfig={{props: {webContentsDebuggingEnabled: true}}}
source={{uri: htmlURL}} />
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Run Code Online (Sandbox Code Playgroud)
关于如何运作的任何想法将受到高度赞赏.