React-Native中一些常用组件的用法详解(一)-创新互联-古蔺大橙子建站
RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
React-Native中一些常用组件的用法详解(一)-创新互联

前言

创新互联是一家专业提供淄川企业网站建设,专注与网站制作、成都网站制作H5页面制作、小程序制作等业务。10年已为淄川众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

本文为大家介绍一下React-Native中一些常用的组件,由于对ES6的语法并没有完全掌握,这里暂时用ES5和ES6混用的语法。

View组件


View是一个支持Flexbox布局、样式、一些触摸处理、和一些无障碍功能的容器,并且它可以放到其它的视图里,也可以有任意多个任意类型的子视图。


View的设计初衷是和StyleSheet搭配使用,这样可以使代码更清晰并且获得更高的性能。尽管内联样式也同样可以使用。

View的常用样式设置

  • flex布局样式
  • backgroundColor:背景颜色
  • borderColor:边框颜色
  • borderWidth:边框大小
  • borderRadius:圆角

以手机端携程官网为示例

import React, { Component } from 'react';
import {
 AppRegistry,
 StyleSheet,
 Text,
 View
} from 'react-native';
var ViewTest = React.createClass({
 render () {
 return (
 
 
  酒店
 
 
  
  海外酒店
  
  
  特价酒店
  
 
 
  
  团购
  
  
  民宿•客栈
  
 
 
 )
 }
});
var styles = StyleSheet.create({
 container: {
 margin: 10,
 marginTop: 25,
 height: 75,
 flexDirection: "row",
 backgroundColor: "#ff607c",
 borderRadius: 5
 },
 flex: {
 flex: 1
 },
 white: {
 color: "white",
 fontWeight: "900",
 textShadowColor: "#ccc",
 textShadowOffset: {width: 1, height: 1}
 },
 center: {
 justifyContent: "center",
 alignItems: "center"
 },
 leftRightLine: {
 borderLeftWidth: 1,
 borderRightWidth: 1,
 borderColor: "white"
 },
 bottomLine: {
 borderBottomWidth: 1,
 borderColor: "white"
 }
});
AppRegistry.registerComponent('HelloReact', () => ViewTest);

本文标题:React-Native中一些常用组件的用法详解(一)-创新互联
标题来源:http://scgulin.cn/article/ccgdpe.html