我已經使用 mui 幾個星期了,每個示例看到styled匯入的方式都不同。一些示例從 匯入@mui/material/styles,其他示例從@mui/system.
在檔案中它只解釋了@mui/system. 我想知道它們的區別。
import { styled } from "@mui/material/styles";
const newButton = styled(Button)({
boxShadow: 'none',
textTransform: 'none',
fontSize: 16,
padding: '6px 12px'
});
// or
import { styled } from "@mui/system";
const newButton = styled(Button)({
boxShadow: 'none',
textTransform: 'none',
fontSize: 16,
padding: '6px 12px'
});
uj5u.com熱心網友回復:
@mui/material/styles是一個遺留包。它與React.StrictMode不兼容,也不適用于 React 18。
@mui/system是舊包的推薦替代方案。
你可以繼續使用@mui/material/styles,但在某個時候它可能不再受支持,并且已經限制你使用舊版本的 React。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/478087.html
