当前位置:首页 > Web开发 > 正文

components:公共css编程组件内部css的插件

2024-03-31 Web开发

react中的css在一个文件中导入,,是全局的,对其他组件的标签都会有影响。

使用styled-components第三方模块来解决

npm i styled-components

import {createGlobalStyle} from ‘styled-components‘; export const GlobalStyled = createGlobalStyle` body{ margin:0; padding:0; background:red; }`

import React from ‘react‘; import {GlobalStyled} from ‘./style.js‘; class App extends React.Components{ render(){ return( <div className=‘App‘> <GlobalStyled /> </div> ) } }

styled-components:公共css编程组件内部css的插件

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/39722.html