我通讀了https://stackoverflow.com/a/69821680/239879并嘗試了該styled方法。我有:
import * as React from 'react';
import { styled } from '@mui/material/styles';
import Tooltip, { TooltipProps, tooltipClasses } from '@mui/material/Tooltip';
const ToBeStyledTooltip = ({ className, ...props }: TooltipProps) => (
<Tooltip { ...props } classes = {{ tooltip: className }} />
);
const StyledTooltip = styled(ToBeStyledTooltip)(({ theme }) => ({
backgroundColor: '#f5f5f9',
color: 'rgba(0, 0, 0, 0.87)',
maxWidth: 220,
border: '1px solid #dadde9',
}));
但是 TypeScript 給了我一個錯誤:
'Tooltip' refers to a value, but is being used as a type here. Did you mean 'typeof Tooltip'?
當我做 a 時build,我得到:
10:11 Error: Parsing error: '>' expected.
不知道我的設定有什么不同。任何幫助,將不勝感激。
uj5u.com熱心網友回復:
確保你在一個.tsx或.jsx檔案上,而不是一個.ts, .js檔案——
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/533331.html
