gpt4 book ai didi

Webpack 警告 : You may need an appropriate loader to handle this file type (date-nfs)

转载 作者:行者123 更新时间:2023-12-01 23:27:44 25 4
gpt4 key购买 nike

我的申请有问题。我有一个网站。我使用 date-fns 来显示基于用户语言的格式化日期。

效果很好,但我更新了 date-fns,从那以后我收到了警告。在我的 JavaScript 代码中,我使用:

const locale = require(`date-fns/locale/${props.match.params.lang}`)

有了这个,我可以像这样生成正确的格式:

format(new Date(), 'D MMMM YYYY', { locale })

它有效,但我不喜欢在构建 webpack 时收到的警告。你能帮我理解我的代码有什么问题吗?如果它在 webpack 配置或包含。

 You may need an appropriate loader to handle this file type.
>frontend | > declare module 'date-fns/locale/fr' { }
>frontend | |
>frontend | @ ./node_modules/date-fns/locale sync ^\.\/.*$ ./fr/index.d.ts
>frontend | @ ./assets/javascripts/features/weather/components/home-header.js
>frontend | @ ./assets/javascripts/features/weather/components/home.js
>frontend | @ ./assets/javascripts/features/weather/containers/home-container.js
>frontend | @ ./assets/javascripts/features/weather/containers/app.js
>frontend | @ ./assets/javascripts/features/weather/index.js
>frontend | @ ./assets/javascripts/app/router.js
>frontend | @ ./assets/javascripts/index.js
>frontend | @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 ./assets/javascripts/index

最佳答案

试试这个:const locale = require(date-fns/locale/${props.match.params.lang}/index.js)

关于Webpack 警告 : You may need an appropriate loader to handle this file type (date-nfs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53818219/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com