React native zIndex不在视图上工作

时间:2017-07-07 21:05:16

标签: javascript react-native z-index react-native-android

以某种方式反应原生zIndex无法处理这段代码......

<View>
    <View style={{backgroundColor: 'red', width: 100, height: 100, zIndex: 1, position: 'absolute', top: 0, right: 0}}/>
    <View style={{backgroundColor: 'blue', width: 50, height: 50, zIndex: 0, position: 'absolute', top: 0, right: 0}}/>
</View>

preview

如果有人能向我解释为什么这是&#34;不工作&#34;那会很棒!

(顺便说一下,这是Android React-native版本0.45.1)

这是我的工作流程atm:

index.android.js

import React from 'react-native';
import Viewport from './app/Viewport';

React.AppRegistry.registerComponent('TSK', () => Viewport);

Viewport.js

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

// Viewport
export default class Viewport extends Component {
    render() {
        return (
            <View>
                <View style={{backgroundColor: 'red', width: 100, height: 100, zIndex: 1, position: 'absolute', top: 0, right: 0}}/>
                <View style={{backgroundColor: 'blue', width: 50, height: 50, zIndex: 0, position: 'absolute', top: 0, right: 0}}/>
            </View>
        );
    }
}

AppRegistry.registerComponent('Viewport', () => Viewport);

0 个答案:

没有答案