render = () => {
let source;
if (__DEV__) {
source = require('./vendor/Editor/index.html');
} else {
source =
Platform.OS === 'ios'
? require('./vendor/Editor/index.html')
: {uri: 'file:///android_asset/vendor/Editor/index.html'};
}
return (
<WebView
startInLoadingState
source={source}
onMessage={this.handleMessage}
automaticallyAdjustContentInsets={false}
style={[
AppStyles.container,
styles.container,
{height: this.state.visibleHeight},
]}
/>
);
};
最后在安卓端调试却变成了这样,webview里显示的全是html源码
写了个简单的页面还是不行...
source = {require('./bar/test.html')}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Title</h1>
<div>
<p>Foo</p>
</div>
</body>
</html>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…