【发布时间】:2021-08-16 20:14:55
【问题描述】:
我认为这可以通过样式化组件实现
使用第一个样式组件 Block 作为另一个组件的基础,例如
export const BlockOne = styled.Block
import React, { Component } from 'react';
import { render } from 'react-dom';
import './style.css';
import styled from 'styled-components'
export const Block = styled.div`
width: 100px;
height: 100px;
background: red;
`
export const BlockOne = styled.Block`
background: yellow;
`
const App = () => {
return (
<div>
<Block/>
<BlockOne/>
</div>
);
}
render(<App />, document.getElementById('root'));
有没有办法做到这一点
【问题讨论】: