1.安装

npm install --save styled-components

2.简单使用

style.js:

import styled from 'styled-components';
import { injectGlobal } from 'styled-components'
export const NavSearch = styled.input.attrs({
placeholder: '搜索'
})`
width: 160px;
height: 38px;
&::placeholder {
color: #999;
}
`;
//全局样式
injectGlobal `
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
`

组件里:

<StyledView>
<StyledText> Hello Marno! </StyledText>
</StyledView>

React-使用styled-components的更多相关文章

  1. styled components草根中文版文档

    1.styled components官网网址 https://www.styled-components.com/docs   以组件的形式来写样式. 1.1安装 yarn add styled-c ...

  2. 【转】Facebook React 和 Web Components(Polymer)对比优势和劣势

    原文转自:http://segmentfault.com/blog/nightire/1190000000753400 译者前言 这是一篇来自 StackOverflow 的问答,提问的人认为 Rea ...

  3. Facebook React 和 Web Components(Polymer)对比优势和劣势

    目录结构 译者前言 Native vs. Compiled 原生语言对决预编译语言 Internal vs. External DSLs 内部与外部 DSLs 的对决 Types of DSLs - ...

  4. [React Fundamentals] Composable Components

    To make more composable React components, you can define common APIs for similar component types. im ...

  5. [React] Higher Order Components (replaces Mixins)

    Higher order components will allow you to apply behaviors to multiple React components. So the idea ...

  6. [React] React Router: Named Components

    In this lesson we'll learn how to render multiple component children from a single route. Define a n ...

  7. [React] 09 - Tutorial: components

    jsx变为js的过程:http://babeljs.io/repl/ youtube: https://www.youtube.com/channel/UCA-Jkgr40A9kl5vsIqg-BIg ...

  8. [React] Write Compound Components

    Compound component gives more rendering control to the user. The functionality of the component stay ...

  9. [React] Break up components into smaller pieces using Functional Components

    We are going to ensure our app is structured in a clear way using functional components. Then, we ar ...

  10. [React Native] Reusable components with required propType

    In this React Native lesson, we will be creating a reusable Badge component. The component will also ...

随机推荐

  1. Java抽象类和接口的比较

    一个软件设计的好坏,我想很大程度上取决于它的整体架构,而这个整体架构其实就是你对整个宏观商业业务的抽象框架,当代表业务逻辑的高层抽象层结构 合理时,你底层的具体实现需要考虑的就仅仅是一些算法和一些具体 ...

  2. 2014年GDG西安 -- DevFest Season1

    今年9月21日,GDG西安组织了第一季以Android Wear为专题的活动,葡萄城则以超一流的办公环境和网络宣传,配合举行了本次活动.下面通过图文方式进行报道,希望未能如期参加的筒子们不要有太多的遗 ...

  3. redis 在Linux下的安装与配置

    redis在Linux下的安装与配置 by:授客  QQ:1033553122 测试环境 redis-3.0.7.tar.gz 下载地址: http://redis.io/download http: ...

  4. 网络基础 http 会话(session)详解

    http 会话(session)详解 by:授客 QQ:1033553122 会话(session)是一种持久网络协议,在用户(或用户代理)端和服务器端之间创建关联,从而起到交换数据包的作用机制 一. ...

  5. 配置Synwrite作为Python的IDE

    先建立批处理 建立SynPython.bat ::Synwrite call Python to compile file ::Set Path @ set PATH=H:\XPprogram\Cod ...

  6. Kotlin入门(13)类成员的众生相

    上一篇文章介绍了类的简单定义及其构造方式,当时为了方便观察演示结果,在示例代码的构造函数中直接调用toast提示方法,但实际开发是不能这么干的.合理的做法是外部访问类的成员属性或者成员方法,从而获得处 ...

  7. Linux文件和目录的粘滞位(sticky bit)

    今天维护系统时发现一个非常诡异的问题:AAA用户和BBB用户同属AAA组,但用AAA用户创建的文件,权限设置为777后,还是不能用BBB用户删除.诡异! 几经周转,发现AAA用户创建文件位置的上层目录 ...

  8. mysql常见的错误代码

    如果安装时或者工作中有问题,可以看错误日志分析问题原因: 1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能 ...

  9. Linux 小知识翻译 - 「端口和端口号」

    这次说说「端口」和「端口号」. 平时经常会听人说「打开了80号端口」,为了安全「不要打开多余的端口」等等.那么,这里的端口或者端口号是什么呢? 首先,「端口」是TCP或者UDP上使用的概念,经常被比喻 ...

  10. 17秋 软件工程 第六次作业 Beta冲刺 Scrum1

    17秋 软件工程 第六次作业 Beta冲刺 Scrum1 各个成员冲刺期间完成的任务 重新梳理项目架构与当前进展,并且对我们的Alpha版本项目进行完整测试,将测试过程中发现的问题列入Github i ...