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. git 查看/修改用户名、密码

    用户名和邮箱地址的作用 用户名和邮箱地址是本地git客户端的一个变量,不随git库而改变. 每次commit都会用用户名和邮箱纪录. github的contributions统计就是按邮箱来统计的. ...

  2. 第一个Django页面(2)

    第一个Django页面 1,进入forum项目:熟悉项目里各种文件的作用 2,配置URL:在urls.py里面添加 [url路径与对应的处理函数] 3,编写处理函数:根据urls.py里添加函数的路径 ...

  3. 跨站请求伪造(CSRF)

    1. 什么是跨站请求伪造(CSRF)  CSRF(Cross-site request forgery跨站请求伪造,也被称为“One Click Attack”或者session Riding,通常缩 ...

  4. 洗礼灵魂,修炼python(21)--自定义函数(2)—函数文档,doctest模块,形参,实参,默认参数,关键字参数,收集参数,位置参数

    函数文档 1.什么是函数文档: 就是放在函数体之前的一段说明,其本身是一段字符串,一个完整的函数需要带有函数文档,这样利于他人阅读,方便理解此函数的作用,能做什么运算 2.怎么查看函数文档: func ...

  5. <转>通过反射获取Form/MenuStrip/ContextMenuStrip等列表

    private void button1_Click(object sender, EventArgs e) { treeView1.Nodes.Clear(); Assembly a = Assem ...

  6. systemd 和 如何修改和创建一个 systemd service (Understanding and administering systemd)

    系统中经常会使用到 systemctl 去管理systemd程序,刚刚看了一篇关于 systemd 和 SysV 相关的文章,这里简要记录一下: systemd定义: (英文来解释更为原汁原味) sy ...

  7. Java概述和项目演示

    Java概述和项目演示 1. 软件开发学习方法 多敲 多思考 解决问题 技术文档阅读(中文,英文) 项目文档 多阅读源码 2. 计算机 简称电脑,执行一系列指令的电子设备 3. 硬件组成 输入设备:键 ...

  8. Flutter在Windows平台下的安装配置

    目录 1. 安装 Flutter SDK2. 设置环境变量3. Flutter doctor4. 安装 Android Studio5. 启动 Android Studio, 安装 Android S ...

  9. win10 文件扩展名的更改

    win10 文件扩展名的改 随便打开一个文件夹,最好是"此电脑",  第二行是 "     文件  -   计算机  -  查看   " 在查看里面就可以更改了 ...

  10. CRM项目之stark组件(1)

    admin组件 admin组件的简单使用 Django 提供了基于 web 的管理工具. Django 自动管理工具是 django.contrib 的一部分.你可以在项目的 settings.py ...