我正在研究 Kyle Simpson 的“你不懂 JavaScript”系列。在(2014 年发布)“Scope & Closures”(第 62 页)的末尾,在 ES6 中有一个使用关键字“module”导入整个模块的示例,如下所示:
// import the entire "foo" and "bar" modules
module foo from "foo";
module bar from "bar";
console.log(
bar.hello( "rhino" )
);
foo.awesome();
Run Code Online (Sandbox Code Playgroud)
但是,此代码不起作用。我的问题是:module关键字是否经过试验和删除?我应该忘记这个关键字吗?
他们是错别字
// import the entire "foo" and "bar" modules
import foo from "foo"; //fixed
import bar from "bar"; //fixed
console.log(
bar.hello( "rhino" )
);
foo.awesome();
Run Code Online (Sandbox Code Playgroud)
有时,书中的例子在错别字上并不是 100% 准确的,它们确实让初学者感到困惑。
| 归档时间: |
|
| 查看次数: |
1207 次 |
| 最近记录: |