Styles | not .scss
// 前端js文件 const styles = {
// 这里不需要像RN一样,使用StyleSheet.create someContainer: { fontSize:16, fontWeight: ‘bold’, }, … }<div style={styles.container} /> |
|
{ flex: 1 1 auto } -> { flexGrow: 1, flexShrink: 1, flexBasis: “auto” } { background: “#DADADA” } -> { backgroundColor: “#DADADA” } |
||
image | <img style={{ width: 98, height: 82 }} src={nullImg} alt=”nullImg” /> | <Image style={{ height: 15, width: 15, marginLeft: 10 }} source={{ uri: ‘search3’ }} /> |
文本 Div -> Text use react-intl-native |
<div>文本</div> <span>文本</span> |
<FormattedMessage style={styles.valueDesc} id=”someId” defaultMessage={text} /> |
响应事件 | onClick -> onPress | |
路由 | react-route | react-navigation, react-native-navigation |
PropTypes react version >= 15.5 |
import React, { Component } from ‘react’; import PropTypes from ‘prop-types’; | |
Global variable | // window window.someVar = var |
// 新建constants.js文件 const object = { website:’http://www.hao123.com’, name:’好123′, }; export default object; // 需要使用时导入 import constants from ‘./constansts.js’ <Text>{constants.name}</Text>
|