美文网首页
ReactNative入门

ReactNative入门

作者: 进击的鸭子 | 来源:发表于2017-06-30 20:42 被阅读0次

在index.ios.js文件中注册并导入组件WeatherProject

/**
 * Sample React Native App
 * index.ios.js 
 * @flow
 */
import React from 'react-native';
import {
  AppRegistry,
} from  'react-native';

import WeatherProject from './WeatherProject';
AppRegistry.registerComponent('AwesomProject', ()=> WeatherProject);

在WeatherProject组件中设置相关的内容:

/**
 * Sample React Native App
 * WeatherProject.js
 * @flow
 */

import React, { Component } from 'react';
import {
  StyleSheet,
  View,
  Text,
  TextInput
} from 'react-native';

export default class AwesomProject extends Component {
  constructor(props){
    super(props);
    this.state = {
      text:''
    }; 
  }

  _handleTextChange (event) {
    this.setState({
      text:event.nativeEvent.text
    });
  }

  render() {
    return (
      <View style = {styles.container}>
        <Text style = {styles.welcome}>
         you input {this.state.text}.
        </Text>
        <TextInput style = {styles.input} onSubmitEditing = {() => this._handleTextChange()} />
      </View>
     
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex:1,
    justifyContent:'center',
    alignItems:'center',
    backgroundColor:'#F5FCFF',    
  },
  welcome:{
    fontSize:20,
    textAlign:'center',
    margin:10,
  },
  input:{
    fontSize:20,
    borderWidth:2,
    height:40,
  },
});

相关文章

  • 慕课视频

    免费 《Web安全-XSS》《ReactNative基础与入门》《React入门》《在React中使用Redux数...

  • Android & iOS 双端

    React Native 入门Doc https://reactnative.cn/docs/next/getti...

  • ReactNative入门

    官网 和 中文网 你将学到如下知识点:1、如何安装React 和一些包。2、如果创建一个工程。3、react ...

  • ReactNative入门

    1. 创建项目 react-native init HelloWord --version 0.43.4 2. 修...

  • ReactNative入门

    在index.ios.js文件中注册并导入组件WeatherProject 在WeatherProject组件中设...

  • ReactNative入门

    ReactNative 入门 1.环境搭建(Mac) HomebrewHomebrew, Mac系统的包管理器,用...

  • ReactNative入门

    目前主流应用程序大体分为三类:Native App, Web App, Hybrid App. 三者各有利弊,具体...

  • ReactNative入门

    因公司业务需要,近半年都在着手开发reactNative应用,在此记录下学习路径,希望对想入门reactNativ...

  • ReactNative 入门

    最近公司有移动端Android 的项目, 使用的技术栈是 ReactNative, 准备学习一下, 了解一下技术栈...

  • Flutter基础(十一)网络请求(Dio)与JSON数据解析

    本文首发于公众号「后厂村码农」 ReactNative入门系列 ...

网友评论

      本文标题:ReactNative入门

      本文链接:https://www.haomeiwen.com/subject/spvicxtx.html