0
我有以下Button.js
:風格組件「CSS」沒有定義沒有民主基金
import styled from 'styled-components';
const Button = styled.button`
background: black;
border: none;
color: white;
outline: none;
${props => props.add && css`
background: palevioletred;
color: white;
`};
${props => props.delete && css`
background: palevioletred;
color: white;
`};
`;
export default Button;
但是當我運行它,我編譯過程中出現以下錯誤:
./src /components/Button.js第10行:「樣式表」沒有定義無爲undef 第15行:「樣式表」沒有定義無爲undef
我然後使用這樣的按鈕:
<Button delete>Delete</Button>
<Button add>Add</Button>
任何我在這裏做錯了嗎?
'道具=> props.add && CSS \'... \''這是JS。此文件中未定義變量'css'。也許'styled.css \'... \''? –
@BalázsÉdes這就是我也認爲,但這並不起作用。 – Tiwaz89