* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.1 KiB
1.1 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7b8d367417b2b2512b59 | 导入一个默认的导出 | 1 | 301205 | import-a-default-export |
--description--
在上一个挑战里,学习了export default
的用法。还需要一种import
的语法来导入默认的导出。
在下面的例子里有一个add
函数, 它在"math_functions"
文件里默认被导出。来看看来如何导入它:
import add from "./math_functions.js";
这个语法只有一处不同的地方 —— 被导入的add
值,并没有被花括号{}
所包围。与导出值的方法不同,导入默认导出的写法仅仅只是简单的将变量名写在import
之后。
--instructions--
在下面的代码中,请导入在同目录下的"math_functions"
文件中默认导出的subtract
值。
--hints--
正确导入export default
方法导出的值。
assert(code.match(/import\s+subtract\s+from\s+('|")\.\/math_functions\.js\1/g));
--seed--
--seed-contents--
// Only change code above this line
subtract(7,4);
--solutions--
import subtract from "./math_functions.js";
subtract(7,4);