我想创建一个订单页面,其中包含两个选项卡下订单选项卡,我的订单选项卡.所以我创建了一个Order.js
文件和另一个OrderContent.js
文件.
Order.js
/* @flow */
import React from 'react'
import {
View,
StatusBar,
} from 'react-native'
import SplashScreen from 'react-native-splash-screen'
import HomeHeader from '../Components/HomeHeader'
import OrderContent from './OrderContent'
export default class OrdersScreen extends React.Component {
static navigationOptions = {
drawer: () => ({
label: 'Orders',
}),
}
static propTypes = {
navigation: React.PropTypes.object.isRequired,
}
componentDidMount() {
SplashScreen.hide()
}
render() {
return (
<View style={{flex: 1, backgroundColor: '#fff'}}>
<StatusBar
barStyle="light-content"
backgroundColor={'#202930'} />
<HomeHeader
title="Order Page"
navigation={this.props.navigation} /> …
Run Code Online (Sandbox Code Playgroud) 我一直在关注如何将现有应用程序与native native集成的指南.http://facebook.github.io/react-native/docs/embedded-app-ios.html#content
根据我们的IOS人员的建议,我对IOS方面的一些自由行动.当我的视图加载时,我得到一个带有堆栈跟踪的红色错误屏幕:
http://puu.sh/jRgDg/b844f139b2.png
(对不起,没有足够的声誉来发布图片.文字包括在下面.)
2015-08-27 22:19:37.739 [error][tid:com.facebook.React.JavaScript] 'Warning: Native component for "RCTImageView" does not exist'
2015-08-27 22:19:37.851 [info][tid:com.facebook.React.JavaScript] 'Running application "SimpleApp" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF'
2015-08-27 22:19:37.856 [error][tid:com.facebook.React.JavaScript] 'Error: undefined is not an object (evaluating \'RCTWebSocketManager.connect\')
stack:
connectToSocketImpl index.ios.bundle:14464
WebSocketBase index.ios.bundle:14587
WebSocket index.ios.bundle:14458
setupDevtools index.ios.bundle:46060
renderApplication index.ios.bundle:44403
run index.ios.bundle:44295
runApplication index.ios.bundle:44323
__callFunction index.ios.bundle:5552
<unknown> index.ios.bundle:5488
guard index.ios.bundle:5441
<unknown> index.ios.bundle:5488
<unknown> index.ios.bundle:5485
perform index.ios.bundle:7033
batchedUpdates index.ios.bundle:16454
batchedUpdates index.ios.bundle:6336
<unknown> …
来自网络背景,根据窗口尺寸绝对定位元素并计算它们在布局中的位置被认为是不好的做法(或不可能).在react-native中,我们可以访问视图端口的维度React.Dimensions
.
例如: let {height, width} = Dimensions.get('window')
我现在可以使用它来设置一个100px元素,方法是:
left: (width/2) - 50
我更喜欢使用更传统的css技术.是不是有理由不这样做?在浏览器中,如果用户调整窗口大小,视口可能会更改,但在移动设备上,视口大小将是静态的.