我有一个文件,这是用来显示我的网站上的标志写在。TSX格式,我无法找出如何写在。JS文件与有关相同的功能。
import React, { FC } from "react";
import { Link } from "react-router-dom";
import styled from "styled-components";
import { Breakpoints } from "../../GlobalStyle";
import useMediaQuery from "./useMediaQuery";
const StyledImage = styled.img<Props>`
height: ${({ height }) => (height ? height : "40px")};
width: auto;
cursor: pointer;
@media (max-width: ${Breakpoints.mobile}px) {
height: 28px;
}
`;
type Props = {
id: string;
height?: string;
};
const ResponsiveLogo: FC<Props> = ({ id, height }) => {
const isMobile = useMediaQuery(`(max-width: ${Breakpoints.mobile}px)`);
let Url = isMobile
? "image1_link"
: "image2_link" ;
return (
<>
<Link to="/">
<StyledImage id={id} height={height} alt={"logo"} src={Url} />
</Link>
</>
);
};
export default ResponsiveLogo;
1条答案
按热度按时间nfeuvbwi1#