我完全按照书上的输入了,但是上面说css没有定义,是因为react的内容改变了很多吗?还是有什么问题?
import React from "react";
import styled from "styled-components";
const StyledButton = styled.button`
border: none;
border-radius: 4px;
font-size: 1rem;
font-weight: bold;
padding: 0.25rem 1rem;
color: white;
outline: none;
cursor: pointer;
background: #343a40;
&:hover {
background: #868e96;
}
${(props) =>
props.fullwidth &&
css`
padding-top: 0.75rem;
padding-bottom: 0.75rem;
width: 100%;
font-size: 1.125rem;
`}
${(props) =>
props.cyan &&
css`
background: #3bc9db;
&:hover {
background: #66d9e8;
}
`}
`;
const Button = (props) => <StyledButton {...props} />;
export default Button;
[eslint]
src\components\common\button.js
Line 21:9: 'css' is not defined no-undef
Line 30:9: 'css' is not defined no-undef
Search for the keywords to learn more about each error.
ERROR in [eslint]
src\components\common\button.js
Line 21:9: 'css' is not defined no-undef
Line 30:9: 'css' is not defined no-undef
Search for the keywords to learn more about each error.
webpack compiled with 1 error
我删除了css的信,并查阅了文献,但我找不到答案。
2条答案
按热度按时间nxowjjhe1#
您需要从
styled-components
包导入css
,因此导入将如下所示:yh2wf1be2#
为什么要使用CSS?
你只要把它取下来就行了