react native识别设备,获取设备屏幕尺寸

在react native开发中可能需要对ios或者android设备使用不同的组件,所以需要识别设备,react-native模块的Platform可以达到这个目的

import React, { Component } from 'react'
import { Platform } from 'react-native'

export default class Navigation extends Component{
    constructor(props){
      super(props)
    }
    render(){

        return Platform.OS == "ios"?():()
    }
}


获取屏幕尺寸可以通过以下方法:

import {Dimensions} from 'react-native'

const deviceH = Dimensions.get('window').height
const deviceW = Dimensions.get('window').width

你可能感兴趣的:(react native识别设备,获取设备屏幕尺寸)