美文网首页iOS Developer
react native:js语法 镶嵌布局的使用

react native:js语法 镶嵌布局的使用

作者: wg689 | 来源:发表于2017-12-31 17:17 被阅读88次
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  Image,
  View,
  ScrollView,
} from 'react-native';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
  'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
  'Shake or press menu button for dev menu',
});

export default class App extends Component<{}> {
  render() {
    return (
      <View >
        <Text style={styles.welcome}>
          嵌套的网格
        </Text>
        <View style={{ flexDirection: 'column', height: 200, backgroundColor: "#cefefe", margin: 0 }}>
          <View style={{ flex: 1, flexDirection: 'column', padding: 5, backgroundColor: "#eeeeee" }}>
            <View style={{ flex: 2, backgroundColor: "yellow" }}>
            </View>
            <View style={{ flex: 1, backgroundColor: "#6abbaa" }}>
            </View>
          </View>
          <View style={{ flex: 1, padding: 5, flexDirection: 'row', backgroundColor: "#7eeeee" }}>
            <View style={{ flex: 2, backgroundColor: "#aaaabb" }}>
              <View style={{ flex: 1, flexDirection: 'row', backgroundColor: "red" }}>
                <View style={{ flex: 1, backgroundColor: "green", padding: 5 }}>
                </View>
                <View style={{ flex: 1, backgroundColor: "#bbccee", padding: 10 }}>
                </View>
              </View>
              <View style={{ flex: 1, backgroundColor: "#eebbdd", padding: 5 }}>
              </View>
            </View>
            <View style={{ flex: 1, backgroundColor: "#aaccaa" }}>
            </View>
          </View>
        </View>
      </View>
    );
  }
}


styles = {

  welcome: {
      fontSize: 20,
      textAlign: 'center',
      margin: 20
  }
}

上述代码运行的效果图:

效果图.png

使用visio code 打开代码 效果分解后看到的效果是

image.png

通过对代码 比对可以看到flex 布局的嵌套使用,和iOS开发布局基本类似


作者开发经验总结的文章推荐,持续更新学习心得笔记

五星推荐 Runtime 10种用法(没有比这更全的了)
五星推荐 成为iOS顶尖高手,你必须来这里(这里有最好的开源项目和文章)
五星推荐 iOS逆向Reveal查看任意app 的界面
五星推荐手把手教你使用python自动打包上传应用分发
JSPatch (实时修复App Store bug)学习(一)
iOS 高级工程师是怎么进阶的(补充版20+点)
扩大按钮(UIButton)点击范围(随意方向扩展哦)
最简单的免证书真机调试(原创)
通过分析微信app,学学如何使用@2x,@3x图片
TableView之MVVM与MVC之对比
使用MVVM减少控制器代码实战(减少56%)
ReactiveCocoa添加cocoapods 配置图文教程及坑总结

相关文章

  • react native:js语法 镶嵌布局的使用

    上述代码运行的效果图: 使用visio code 打开代码 效果分解后看到的效果是 通过对代码 比对可以看到fle...

  • React Native学习资料

    React 入门实例教程React-Native入门指南Flex 布局教程:语法篇React Native探索(二...

  • 我的收藏

    结合flexible.js的rem布局方案 如何在Vue项目中使用vw实现移动端适配 React Native 项...

  • React Native创建新项目

    前言 React Native 是基于 React 框架搭建而成的,使用的是JavaScript语法。React ...

  • 资源帖

    结合flexible.js的rem布局方案 React Native 项目转换为react web项目方案 MAC...

  • React Native 布局

    React Native 版本 0.55.4 在使用React native 开发过程中,遇到了很多布局问题。 一...

  • ReactJS第一天

    引包&安装 React官网 react.js react-dom.js browser.js 使用JSX语法 JS...

  • React Native 之 flexbox布局

    React Native 之 flexbox布局 本文详情本文讲解React Native中的布局,该布局用CSS...

  • React-Native的实现原理

    React-Native:可以用JSX(JS的语法扩展) 混编js、css、html,只关心如何用 JavaScr...

  • react-native开发环境搭建的坑

    React-native安装的那些坑 React-native 官网声称可以让前端开发者使用js和React开发出...

网友评论

    本文标题:react native:js语法 镶嵌布局的使用

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