我正在嘗試在我的 React 專案中使用 MUI 的資料網格組件。我已經使用 $npm i @mui/x-data-grid 安裝了這個包。當我將 DataGrid 匯入我的 React 組件并運行 $npm start 時,我收到以下 ENOENT 錯誤。有誰知道為什么?

注釋掉匯入后,錯誤消失:

我為解決此問題而采取的步驟:
- 重新啟動 VS 代碼
- 重新啟動我的電腦
- 從https://www.codejourney.net/2021/04/how-to-fix-npm-err-enoent-enoent-no-such-file-or-directory-rename/運行“修補程式”
uj5u.com熱心網友回復:
因為它C:\Users\<user>\Pictures從 Windows 8重命名為?
順便說一句,您為什么要嘗試訪問專案目錄之外的影像?它有效,但管理起來將是一場噩夢。
例如,當您必須將代碼推送到 GitHub 時,您打算怎么做?包含C:\Users\<user>\Pictures在您的源代碼中?
uj5u.com熱心網友回復:
我認為這是由@material-ui/core 和@mui/x-data-grid 之間不兼容引起的問題。
我發現了一些可能的解決方案:
- 使用 Webpack 別名通過https://githubmemory.com/repo/mui-org/material-ui-x/issues/2527規避問題
- 安裝舊版本的 MUI 資料網格:https : //github.com/mui-org/material-ui-x
- 使用資料網格組件的第三方選項。我決定繼續進行以下操作:https : //github.com/adazzle/react-data-grid/blob/main/README.md
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/362253.html
