【问题标题】:Uncaught TypeError: Object(...) is not a function when importing @material-ui/pickersUncaught TypeError: Object(...) is not a function when importing @material-ui/pickers
【发布时间】:2019-05-06 18:04:16
【问题描述】:

我正在使用 "@material-ui/core": "^3.9.3""@material-ui/pickers": "^3.0.0-beta.1"

当我从 @material-ui/pickers 导入任何内容时,我得到:

Uncaught TypeError: Object(...) is not a function
at Module../node_modules/@material-ui/pickers/dist/material-ui-pickers.esm.js (material-ui-pickers.esm.js:25)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Module../src/views/Event/Create.js (User.js:18)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Module../src/Routes.js (Routes.js:1)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Module../src/layouts/Admin.jsx (index.js:73)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Module../src/index.js (index.css?02e3:45)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Object.0 (Notifications.jsx:300)
at __webpack_require__ (bootstrap:781)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1

【问题讨论】:

    标签: material-ui


    【解决方案1】:

    确保 @material-ui/pickers 是新的 npm 包,服务于下一个版本。它是必需的@material-ui/core 至少 v4.0.0-beta.0

    material-ui老v3版本,使用material-ui-pickers包和v2.2.4版本

    【讨论】:

    • 我是否在文档中遗漏了有关所需版本的内容?抱歉,刚开始使用 MUI。