带有样式组件的材料UI -Freededas从未工作
我正在使用react
,材料ui
样式组件
。
您能帮我调整一下吗? 转发
不起作用。
coursassage.style.js
import styled from 'styled-components';
import { Button as ButtonComponent } from '../../components/Button/Button';
export const Button = styled(ButtonComponent)`
text-decoration: none;
`;
coursasspage.jsx
import { Link } from 'react-router-dom';
import { Button } from './CoursesPage.style';
<Button
to='/courses/add'
variant='outlined'
size='small'
forwardedAs={Link}
>
Add new course
</Button>
button.jsx
import { StyledButton } from './Button.style';
export const Button = (props) => (
<StyledButton {...props}>{props.children}</StyledButton>
);
button.style.jsx
import { styled } from '@mui/material/styles';
import MUIButton from '@mui/material/Button';
export const StyledButton = styled(MUIButton)`
color: #000;
border: 1px solid #474747;
text-transform: initial;
&:hover {
background-color: #d0d0d0;
border: 1px solid #474747;
}
`;
I am using React
, Material UI
with styled-components
.
Could you please help me to adjust that? forwardedAs
doesn't work.
CoursesPage.style.js
import styled from 'styled-components';
import { Button as ButtonComponent } from '../../components/Button/Button';
export const Button = styled(ButtonComponent)`
text-decoration: none;
`;
CoursesPage.jsx
import { Link } from 'react-router-dom';
import { Button } from './CoursesPage.style';
<Button
to='/courses/add'
variant='outlined'
size='small'
forwardedAs={Link}
>
Add new course
</Button>
Button.jsx
import { StyledButton } from './Button.style';
export const Button = (props) => (
<StyledButton {...props}>{props.children}</StyledButton>
);
Button.style.jsx
import { styled } from '@mui/material/styles';
import MUIButton from '@mui/material/Button';
export const StyledButton = styled(MUIButton)`
color: #000;
border: 1px solid #474747;
text-transform: initial;
&:hover {
background-color: #d0d0d0;
border: 1px solid #474747;
}
`;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论