英文:
Material UI @mui/material/Button vs @material-ui/core/Button, when did it change, where are docs for older version
问题
我想将Material UI添加到我正在开发的React项目中。快速搜索出现了这篇文章Medium.com文章:入门Material-UI For React。
我开始观看视频,其中说要使用:
npm install @material-ui/core
并在代码中使用:
import Button from '@material-ui/core/Button'; // 语法 #1
但我遇到了问题,所以查看了官方MUI文档,其中说:
npm install @mui/material @emotion/react @emotion/styled
并使用:
import Button from '@mui/material/Button'; // 语法 #2
这两个版本都来自同一个Material UI团队吗?如果是这样,我如何获取旧版文档?还是最好使用最新版本(语法 #2)的Material UI 5.13.x,并只使用https://mui.com网站?
寻找解决方案
- 转到旧网站https://material-ui.com 只会重定向到新网站https://mui.com/core/。
我发现两种语法都在使用:
-
按钮API - https://mui.com/material-ui/api/button/ - 使用语法 #2
-
https://www.geeksforgeeks.org/material-ui-button-api/# - 使用语法 #1
-
为什么应该升级到Material-UI V5 来自https://marmelab.com/blog/...
-
https://mui.com/material-ui/getting-started/overview/#material-ui-vs-base-ui 这个没有回答我的问题。 - 使用语法 #2,所以可能v5引入了新的命名空间和语法。
英文:
I wanted to add Material UI to a React project I'm working on. A quick searched turned up the article Medium.com article Getting Started With Material-UI For React.
I started watching the video which said to use:
npm install @material-ui/core
And in the code to use:
import Button from '@material-ui/core/Button' // Syntax #1
But I ran into problems, so looked at the offical MUI docs which say:
npm install @mui/material @emotion/react @emotion/styled
And using
import Button from '@mui/material/Button'; // Sytnax #2
Are both versions from the same Material UI team? If so, how do I get the older docs? Or would it be better to use the latest version (Syntax #2) of Material UI 5.13.x and just use the https://mui.com website?
Searching for solution
- Going to old website https://material-ui.com simply redirects to new site https://mui.com/core/.
I found both both syntaxs being used:
-
Button API - https://mui.com/material-ui/api/button/ - Uses syntax #2
-
https://www.geeksforgeeks.org/material-ui-button-api/# - Uses syntax #1
-
Why You Should Upgrade To Material-UI V5 from https://marmelab.com/blog/...
-
https://mui.com/material-ui/getting-started/overview/#material-ui-vs-base-ui which did not answer my question. - Uses Syntax #2 so perhaps v5 introduced the new namespace and syntax.
答案1
得分: 1
以下是已翻译好的内容:
在 material-ui
推出第5版本后,团队将 material-ui
重命名为 mui
,已重命名的包列表如下:
@material-ui/core -> @mui/material
@material-ui/system -> @mui/system
@material-ui/unstyled -> @mui/core
@material-ui/styles -> @mui/styles
@material-ui/icons -> @mui/icons-material
@material-ui/lab -> @mui/lab
@material-ui/types -> @mui/types
@material-ui/styled-engine -> @mui/styled-engine
@material-ui/styled-engine-sc ->@mui/styled-engine-sc
@material-ui/private-theming -> @mui/private-theming
@material-ui/codemod -> @mui/codemod
@material-ui/docs -> @mui/docs
@material-ui/envinfo -> @mui/envinfo
英文:
After material-ui
introduced the 5th version, the team renamed material-ui
to mui
, list of renamed packages:
@material-ui/core -> @mui/material
@material-ui/system -> @mui/system
@material-ui/unstyled -> @mui/core
@material-ui/styles -> @mui/styles
@material-ui/icons -> @mui/icons-material
@material-ui/lab -> @mui/lab
@material-ui/types -> @mui/types
@material-ui/styled-engine -> @mui/styled-engine
@material-ui/styled-engine-sc ->@mui/styled-engine-sc
@material-ui/private-theming -> @mui/private-theming
@material-ui/codemod -> @mui/codemod
@material-ui/docs -> @mui/docs
@material-ui/envinfo -> @mui/envinfo
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论