首页 > TAG信息列表 > styled-components

将Javascript变量与样式组件一起使用

我正在使用styled-components来构建我的组件.接受自定义值的所有样式属性都会在我的组件中重复使用(应该如此).考虑到这一点,我想使用某种全局变量,以便更新将传播到所有组件,而无需单独更新每个样式. 像这样的东西: // Variables.js var fontSizeMedium = 16px; // Section.js

javascript – 在React Styled Components上使用’ref’不起作用

我在使用样式组件的refs时遇到了困难.当我尝试在我的类方法中访问它们时,我收到以下错误: Edit.js:42 Uncaught TypeError: this…..contains is not a function constructor(props) { .... this.setWrapperRef = this.setWrapperRef.bind(this); this.handleClick

javascript – 在模板文字中定义一个函数

我正在使用styled-components作为React样式的解决方案.他们有一个很好的方法,使用模板文字插入CSS.模板文字传递组件的道具,以便您可以执行以下操作: const PasswordsMatchMessage = styled.div` background: ${props => props.isMatching ? 'green' : 'red'}; ` 结果是一个组

javascript – 在React Native中为样式化组件自定义组件添加样式

我有button.js: import React from "react"; import styled from "styled-components"; const StyledButton = styled.TouchableOpacity` border: 1px solid #fff; border-radius: 10px; padding-horizontal: 10px; padding-vertical: 5px; `; c