React Native的slogan是learn once, run anywhere,显然不是write once, run anywhere。 React Native提供了一套JS解决iOS和android应用开发的方案,但是它并非一个写一种代码能跑在多个平台的方案(当然,使用react native也可以write once, run anywhere,但是在视觉美观度和app性能方面可能会做某些程度的牺牲)。
说明: Tabbed navigation that you can swipe between, each tab can have its own ScrollView and maintain its own scroll position between swipes. Pleasantly animated. Customizable tab bar https://www.npmjs.com/package/react-native-scrollable-tab-view
import React, { Component } from 'react' import { AppRegistry, StyleSheet, Text, View } from 'react-native'
export default class Root extends Component { render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Welcome to Railay! </Text> <Text style={styles.instructions}> This is the line one </Text> <Text style={styles.instructions}> Refresh : CMD + R for iOS / Double R for Android,{'\n'} Menu: Cmd + D / Menu or shake for dev menu! </Text> </View> ); } }