css - CSS 与 React Native
问题描述
所以我正在用经典的 CSS 运行 react native。我正在尝试通过使用 CSS 设置颜色变量来设置配色方案。从标题开始:
header.module.css:
:root {
--brand-Black: '#0A0908';
--secondary-Black: '#27262C';
--brand-Blue-light: '#86BBD8';
--brand-Green: '#247B9F';
--brand-Gold: '#DBAD06';
--brand-Blue-dark: '#005AA4';
--brand-Blue: '#4392F1';
--brand-Red: '#DB2955';
--brand-Red-dark: '#831933';
--brand-Grey: '#999999';
}
.text-default {
color: blue;
font-style: normal;
font-weight: bold;
font-size: 63px;
line-height: 64px;
display: flex;
align-items: center;
}
.container {
display: flex;
flex-direction: row;
width: 100%;
height: 147px;
padding-top: 24px;
background-color: var(--brand-Blue-light);
}
我抓住了容器的容器类,但颜色没有出现。我究竟做错了什么?有任何想法吗?
这里也是 header.js 文件:
import React from 'react';
import {Image, Text, View} from 'react-native';
import styles from '../../assets/styles/Header.module.css';
import colors from '../../config/colors';
export default class Header extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={styles.container}>
<Text style={styles.title} >{this.props.name}</Text>
<Image
style={styles.image}
source={{
uri: this.props.image,
}}
/>
</View>
);
}
}
解决方案
不可能。您必须将样式编写为对象,通常使用“StyleSheet.create({})”完成:https ://reactnative.dev/docs/stylesheet
推荐阅读
- python - 我如何在 Python 中使用 pandas 多年来每月分组?
- apollo - WebSocket 连接到“ws://localhost:4444/subscriptions”失败:WebSocket 在连接建立之前关闭
- highcharts - Highcharts如何以编程方式放大?与您选择和区域进行视觉缩放时相同吗?
- sql - TediousJS 问题
- flutter - 如何在 Dart 中初始化嵌套对象。NoSuchMethodError:null 上的无效成员:'user'
- powershell - 初学者问题:如何使用powershell脚本审计/验证远程服务器本地管理员组成员是否正确
- angular - Firebase RealTime DataBase:显示与某个类别匹配的对象(Angular)
- object - 经典 ASP 通过 global.asa 定义和使用全局对象
- red5 - 我可以在安全端口 443 red5pro 上看到实时应用程序
- elasticsearch - 查询字符串为空时返回所有文档