stylesheet独立文件问题



  • 项目想把stylesheet独立成文件管理,所以把stylesheet放单独的文件,但是一直出错。
    样式storestyle.js

    import React, {StyleSheet, Dimensions, PixelRatio} from "react-native";
    const {width, height, scale} = Dimensions.get("window"),
    vw = width / 100,
    vh = height / 100,
    vmin = Math.min(vw, vh),
    vmax = Math.max(vw, vh);

    export default StyleSheet.create({
    "loginbanner": {
    "flex": 1,
    "height": 120,
    "resizeMode": React.Image.resizeMode.stretch
    },
    "menucontent:": {
    "flexDirection": "row",
    "flex": 1,
    "marginBottom": 40
    },
    "heighttop:": {
    "height": 48
    },
    "leftmenu:": {
    "flex": 1,
    "flexDirection": "column",
    "borderStyle": "solid",
    "borderRightColor": "#dddddd",
    "borderRightWidth": 1,
    "position": "relative",
    "top": 0,
    "bottom": 0
    },
    "rightcontent:": {
    "flex": 3.5
    },
    "lefttext:": {
    "height": 40,
    "justifyContent": "center",
    "alignItems": "center",
    "backgroundColor": "#f4f4f4",
    "borderBottomColor": "#dddddd",
    "borderBottomWidth": 1
    },
    "lastlefttext:": {
    "backgroundColor": "#f4f4f4",
    "borderBottomColor": "#dddddd",
    "borderBottomWidth": 1,
    "alignSelf": "stretch",
    "position": "absolute",
    "top": 0,
    "bottom": 0,
    "alignItems": "stretch"
    },
    "lefttoptextview:": {
    "height": 35,
    "justifyContent": "center",
    "alignItems": "center",
    "backgroundColor": "#ffffff",
    "borderBottomColor": "#dddddd",
    "borderBottomWidth": 1
    },
    "lefetoptext:": {
    "color": "#fe9b6d",
    "fontSize": 12
    },
    "righttitle:": {
    "height": 40,
    "justifyContent": "center",
    "borderColor": "#dddddd",
    "borderWidth": 1,
    "borderStyle": "solid",
    "borderLeftWidth": 0,
    "backgroundColor": "#fafafa"
    },
    "righttitletext:": {
    "color": "#666666",
    "paddingLeft": 8,
    "fontSize": 12
    },
    "cartcontainer:": {
    "height": 40,
    "position": "absolute",
    "bottom": 0,
    "right": 0,
    "left": 0,
    "backgroundColor": "#f6f6f6",
    "borderTopColor": "#eeeeee",
    "borderStyle": "solid",
    "borderTopWidth": 1,
    "flexDirection": "column"
    }
    });

    引用:
    import styles from './style/storestyle';

    调试一直提示styles未被定义。

    曾经试着换成require的方式,但是取值还是有问题。





  • 谢谢,已参考,找到问题了。