使用名为导入声明的ES6时,Webstorm中出现错误:
import { nodes } from 'utils/dom';
我在“节点”上收到“无法解析符号”错误
另外,当我尝试像这样导出为命名导出时:
export {
write: document.write.bind(document),
node: document.querySelector.bind(document),
nodes: document.querySelectorAll.bind(document)
};
我也收到错误。我将eslint与babel-eslint解析器结合使用。事实是,它可以在Sublime Text 3中作为附件使用,但是由于某种原因,Webstorm中的错误检查失败。
我认为这是因为除了Eslint webstorm之外,它还在进行其他代码检查。
知道我如何抑制这种情况,并且只将eslint与babel-eslint解析器一起使用吗?
任何建议将被认真考虑
我在“节点”上收到“无法解析符号”错误
是因为utils/dom
在标准Node代码中,意思是“在名为'utils'的模块中找到dom.js。您已经通过使用webpack的moduleDirectories
属性来覆盖此行为,但是WebStorm不知道这是什么。要正确地解决WebStorm utils/dom
,您需要utils
在Webstorm项目配置中将该文件夹添加为库。
您的export
语法不正确。ES6导入/导出语法与对象无关100%,在示例导出中,您正在使用对象语法。import { nodes }
正在要求出口名为nodes
。您可以通过多种方式编写导出的内容:
export const write = document.write.bind(document);
export const node = document.querySelector.bind(document);
export const nodes = document.querySelectorAll.bind(document);
或者,如果您喜欢多行,也可以折叠它们 var/let/const
export const write = document.write.bind(document),
node = document.querySelector.bind(document),
nodes = document.querySelectorAll.bind(document);
甚至
const write = document.write.bind(document);
const node = document.querySelector.bind(document);
const nodes = document.querySelectorAll.bind(document);
export {write, node, nodes};
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句