我的应用程序有问题。我有一个网站。我使用 date-fns 根据用户语言显示格式化日期。
它工作得很好,但我更新了 date-fns,从那以后我收到了一个警告。在我的 JavaScript 代码中我使用:
const locale = require(`date-fns/locale/${props.match.params.lang}`)
这样,我就可以生成正确的格式,如下所示:
format(new Date(), 'D MMMM YYYY', { locale })
它有效,但我不喜欢 webpack 构建时收到的警告。你能帮我理解我的代码有什么问题吗?如果它在 webpack 配置或 include 中。
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
尝试这个:
常量语言环境 = 要求(date-fns/locale/${props.match.params.lang}/index.js
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)