styled-components-生成样式组件

1.优点:贯彻React的everything in JS理念,降低js对css文件的依赖;
            组件的样式和其他组件完全解耦,有效避免组件之间的样式污染
2.使用:
    安装:npm install --save styled-components
    代码:
        //创建一个样式组件,其渲染后为一个div
        const Wrapper = styled.div`
                   color: red;
          `
//使用该组件,与其他组件一样 <Wrapper>Hello Word!</Wrapper>

参考:https://www.jianshu.com/p/2d5f037c7df9

posted @ 2021-12-09 17:38  天官赐福·  阅读(55)  评论(0)    收藏  举报
返回顶端