根据此来源和在某个地方的项目中看到过这种用法的模糊记忆,我很好奇是否有人能够执行以下操作:
According to this source and a vague memory of having seen this sort of usage in a project somewhere, I'm curious if anyone has been able to do the following:
import {map: { series }} from 'contra'解构分配概述:
ES6中的import语句的行为类似于解构,但是它 重要的是要注意它实际上并没有破坏性.
The import statement in ES6 behaves similarly to destructuring, but it is important to note that it is not actually destructuring.
看来,导入的工作方式略有不同,也许不能指望相同的确切行为,但是我无法验证其状态.我要尝试做的是ECMAScript 6/7官方规范的一部分吗?
It appears that imports work a little different and perhaps one cannot expect the same exact behavior, but I haven't been able to verify the status of this. Is what I am trying to do part of the official ECMAScript 6/7 spec?
在尝试回答此问题时,请包括(或链接)规范中澄清此问题的部分.
In attempting to answer this, please kindly include (or link) the portion of the spec that clarifies this concern.
推荐答案规范的相关部分为此处.
ImportDeclaration 是
import ImportClause FromClause ;
如果检查 ImportClause ,您会发现它只是熟悉的* as Foo或DefaultImport或{ImportSpecifier, ...}等,其中 ImportSpecifier 是一个 ImportBinding ,它又是一个 BindingIdentifer ,它只是一个普通的 Identifier .
If you examine ImportClause, you'll see it's just the familiar * as Foo, or DefaultImport, or {ImportSpecifier, ...}, etc., where ImportSpecifier is an ImportBinding, which in turn is a BindingIdentifer, which is just a plain old Identifier.
MDN条目介于误导和完全错误之间.它应该说过(现在确实说过):
The MDN entry is somewhere between misleading and completely wrong. It should have said (and now does say):
ES6中的import语句与销毁表面上相似,但实际上是完全不相关的.
The import statement in ES6 has a superficial resemblance to destructuring, but is actually completely unrelated.
这些天来,我在MDN中发现了越来越多的错误和误导性信息.应该与一粒盐一起服用.权威参考是规范.
I find more and more incorrect and misleading information in MDN these days. It should be taken with a grain of salt. The authoritative reference is the spec.
更多推荐
导入语句中的销毁分配
发布评论