React-使用styled-components
发布时间:2020-12-15 20:25:31 所属栏目:百科 来源:网络整理
导读: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: 16
1.安装 npm install --save styled-components
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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |