React-native外部引入样式

来源:互联网 发布:数据库表显示使用中 编辑:程序博客网 时间:2024/05/29 06:48

指定的文件夹中创建styles.js 我的是放在css文件夹中

代码如下

importReact from 'react';
import {
StyleSheet
} from 'react-native';

varstyles= StyleSheet.create(
{
div:{
width:500,
height:200,
backgroundColor:"blue"
},
});

module.exports =styles;
要引入该样式则需要

import stylesfrom './css/styles'
使用方法还是一样具体如下代码

<Viewstyle={style.div}></View>