美文网首页
RN学习笔记 styles和枚举定义

RN学习笔记 styles和枚举定义

作者: 金丝楠 | 来源:发表于2019-10-24 16:09 被阅读0次

    styles.js定义

    const CellHeight = 50; 
    const LeftInterval = 16; 
    const MeltOutButtonHeight = 42; 
    
    export default {
      container: {
        height: CellHeight * 7 + MeltOutButtonHeight + 28 + 20,
        backgroundColor: "#FFFFFF"
      },
      validityView: {
        flexDirection: "row",
        height: CellHeight
      },
      separator: {
        backgroundColor: "#E9E9E9",
        height: 0.5
      },
      cellSeparator: {
        backgroundColor: "#E9E9E9",
        height: 1,
        marginLeft: LeftInterval,
        width: screenW - 2 * LeftInterval
      },
    

    styles.js引用

    import MeltStyles from "./meltStyles";
    
    // 从styles.js中取值
    const { CellHeight } = MeltStyles;
    
    // 该行代码代替const styles = StyleSheet.create({})
    const styles = MeltStyles;
    

    枚举定义

    /**
     * zq类型
     */
    export const SecuritysEnum = {
      starMarket: 0,
      mainBoard: 1
    };
    
    /**
     * kh类型
     */
    export const CustomersEnum = {
      internal: 0,
      external: 1
    };
    

    枚举读取

    import { SecuritysEnum, CustomersEnum } from "./components/securityMacro";
    
      static defaultProps = {
        securityType: SecuritysEnum.mainBoard,
        customerType: CustomersEnum.external,
      };
    

    相关文章

      网友评论

          本文标题:RN学习笔记 styles和枚举定义

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