0

React native 与 React 的区别

 2 years ago
source link: https://yjalifebook.com/react-native-%e4%b8%8e-react-%e7%9a%84%e5%8c%ba%e5%88%ab/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

React native 与 React 的区别Skip to content

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>

欢迎大家关顾我的Facebook主页「Y Life Book」以及我的公众微信号「不点语书」,我们下期见。

Post navigation

Leave a Comment Cancel Reply

Your email address will not be published. Required fields are marked *

Type here..

Name*

Email*

Website

Save my name, email, and website in this browser for the next time I comment.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK