【问题标题】:Importing default and named imports from a file is not working?从文件导入默认和命名导入不起作用?
【发布时间】:2020-03-18 10:05:15
【问题描述】:

我的 .js 文件中有这些导出:

export const title = 'Message \n + one';
export const placeHolder = 'Message two';
export default data; //array

然后我将它导入到我想使用它的文件中:

import data, { placeHolder, title } from '../components/data/event-data';

但“标题”带有下划线

title not found in '../components/data/event-data'(import/named)

为什么? 提前谢谢你

【问题讨论】:

  • 您确定不是缓存问题吗?从您的导出语句中,命名导出 placeHoldertitle 都应该可用:)
  • 您使用的是github.com/benmosher/eslint-plugin-import 还是类似的?这看起来像是一个 linting 错误,并且 linter 或插件可能有错误。
  • 谢谢。解决了。同时缓存 eslint 规则。

标签: javascript ecmascript-6 es6-modules


【解决方案1】:

缓存和 ESLint 规则问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-25
    • 2022-11-02
    • 2022-07-10
    • 2020-01-03
    • 2018-08-26
    • 2021-10-08
    • 2020-05-12
    • 2021-01-19
    相关资源
    最近更新 更多