【发布时间】:2016-02-17 11:01:42
【问题描述】:
我正在关注 react-native 文档中的示例,但不知道为什么我的 webview 无法加载网站。
这是我的代码:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View,
Image,
TextInput,
Button,
TouchableHighlight,
TouchableOpacity,
StatusBarIOS,
WebView
} from 'react-native';
StatusBarIOS.setStyle(1);
import Dimensions from 'Dimensions';
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;
var CStyles = require('./CStyle');
class TestComp extends Component {
constructor(){
super();
this.state = {
url: 'https://www.google.at/'
}
}
render() {
return (
<View style={{flex: 1}}>
<WebView
ref="webview"
style={{width: width}}
automaticallyAdjustContentInsets={false}
source={{uri: this.state.url}}
javaScriptEnabled={true}
domStorageEnabled={true}
decelerationRate="normal"
startInLoadingState={true}
/>
</View>
);
}
}
module.exports = TestComp;
现在我所看到的只是一个指示正在加载的东西的微调器。但什么都没有改变。
我做错了什么?
根据评论者的说法,这似乎是一个基本问题,我已经为此打开了一个 GH Issue,请随时贡献 https://github.com/facebook/react-native/issues/5974
【问题讨论】:
-
不,我用纯 html 代码试了一下,它也说正在加载。我猜RN有bug,试试在github上开一个issue。
-
我会这样做并将链接粘贴到这里
-
@noa-dev 我试图重现这个问题。 CStyle 的内容是什么?
var CStyles = require('./CStyle');这个例子出自哪里? -
文件 CStyle 仅包含一个导出的对象,用作样式表。
标签: webview react-native