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. FreeSSHD login with permission denied

    登录遇到问题: Permission denied, please try again. 解决方法: 在window中使用freesshd开启ssh后,客户端登陆时报 access denied错误 ...

  2. Linux 学习笔记之超详细基础linux命令(the end)

    Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 14---------------- ...

  3. http协议及长连接和短连接

    1. HTTP协议与TCP/IP协议的关系 HTTP的长连接和短连接本质上是TCP长连接和短连接.HTTP属于应用层协议,在传输层使用TCP协议,在网络层使用IP协议. IP协议主要解决网络路由和寻址 ...

  4. (后端)Java跨域过滤器

    private FilterConfig config = null; @Override public void init(FilterConfig config) throws ServletEx ...

  5. weblogic系列漏洞整理 -- 4. weblogic XMLDecoder 反序列化漏洞(CVE-2017-10271、CVE-2017-3506)

    目录 四. weblogic XMLDecoder 反序列化漏洞(CVE-2017-10271) 0. 漏洞分析 1. 利用过程 2. 修复建议 一.weblogic安装 http://www.cnb ...

  6. 洗礼灵魂,修炼python(44)--巩固篇—反射之重新认识hasattr,gettattr,setattr,delattr

    不急着进入正题.先动手完成一个小程序: 设计一套简单的服务开启关闭程序,每次开启或关闭都得打印服务当前的状态: class Server(object): def __init__(self): se ...

  7. Beta冲刺(4/5)(麻瓜制造者)

    今日已完成 邓弘立:完成了商品管理(下架)和搜索功能 符天愉:完成了后台管理员界面的登录和其他视图的载入 江郑:昨天来决定跨域执行请求,后台参考一些意见以后,操作起来没有那么容易实现,和队友交流以后本 ...

  8. (下一篇博客)提示5G信道

    原本注册这个博客是要不定期更新一些产品的测试内容的 但由于一些个人原因并没有坚持去做到, 每次有点子的时候却没能来得及记下来导致很内容的缺失 接下来将关键点以图片形式 和一些摘要形式先发上来, 已做备 ...

  9. jeDeta 日历控件的那些坑

    经过亲自测试 jeDeta 发现 jeDeta 还是有坑的: 1.参数 options 里面的 format 有很多种格式 API 里面写的是 format: 'YYYY-MM-DD hh:mm:ss ...

  10. python下载脚本

    #/usr/bin/env python#coding:UTF-8import timeimport os,sysimport urllib2 url = 'http://downloaduat.la ...