我可以只添加 Material-UI Lab 到我的项目而不安装 Core 吗?

Can I add only Material-UI Lab to my project without installing Core?

我想在我的 React 应用程序中使用来自 Material UI 的 Slider 组件。 滑块是 'Lab'、'package that hosts the incubator components that are not yet ready to move to the core.'

的一部分
npm install @material-ui/lab
npm install @material-ui/core

我是否仍需要将核心 Material UI 安装到我的项目中,或者我是否可以只添加实验室? 我不想在我已经很大的项目中增加更多的体积。

@material-ui/lab 依赖于@material-ui/core,因此您必须添加@material-ui/core。您可以选择如何添加 npm install 或 cdn

我猜这里有一些对你有用的:

@material-ui/core cdn 参考:

@material-ui/lab cdn 参考:Here

或者你可以试试ant.design 他们为您准备了一些很棒的工具。

谢谢你:)

@material-ui/lab 具有 @material-ui/core 作为对等依赖项。所以是的,你确实需要添加它。但是,如果您担心包的大小,那么请放心,导入实验室组件不会将完整的核心添加到包中。它只会添加必要的内容。