导入错误./node_modules/@mui/x-date-pickers/AdapterDateFns/AdapterDateFns.js 58:0-65

问题描述 投票:0回答:1

./node_modules/@mui/x-date-pickers/AdapterDateFns/AdapterDateFns.js 中的错误 58:0-65 找不到模块:错误:包路径 ./_lib/format/longFormatters 未从包 C:\Users\ykd\git\BookHaircutApp rontend-react 导出 ode_modules\date-fns (请参阅 C:\Users\ykd\git\BookHaircutApp rontend-react 中的导出字段 ode_modules\date-fns\package.json)

我的进口:

import React, { useState } from 'react';
import TextField from '@mui/material/TextField';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker';
import Badge from '@mui/material/Badge';
import { PickersDay } from '@mui/x-date-pickers/PickersDay';
import CheckIcon from '@mui/icons-material/Check';
javascript reactjs datepicker calendar
1个回答
0
投票

改变:

import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';

至:

import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3'

更多信息在这里:https://mui.com/x/react-date-pickers/getting-started/#setup-your-date-library-adapter

这里:https://github.com/mui/mui-x/issues/12144#issuecomment-1953729205

但基本上,为了支持 date-fns v2 和 v3,mui-x 团队必须创建 2 个适配器。在将 date-fns 从 v2 更新到 v3 后,您可能会发生这种情况。

© www.soinside.com 2019 - 2024. All rights reserved.