mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-06 06:39:18 -05:00
2.0 KiB
2.0 KiB
id, challengeType, forumTopicId, title
| id | challengeType | forumTopicId | title |
|---|---|---|---|
| 5cddbfd622f1a59093ec611d | 6 | 301198 | 创建一个模块脚本 |
Description
module 的脚本。例子如下:
<script type="module" src="filename.js"></script>
使用了 module 类型的脚本后可以再接下来的挑战里使用 import 和 export 特性。
Instructions
module 类型的脚本,指定源文件为 index.js。
Tests
tests:
- text: 应该创建一个 <code>script</code> 标签。
testString: assert(code.match(/<\s*script[^>]*>\s*<\/\s*script\s*>/g));
- text: <code>script</code> 标签的类型应该为 <code>module</code>。
testString: assert(code.match(/<\s*script\s+[^t]*type\s*=\s*('|")module\1[^>]*>\s*<\/\s*script\s*>/g));
- text: <code>script</code> 标签的 <code>src</code> 属性应该为 <code>index.js</code>。
testString: assert(code.match(/<\s*script\s+[^s]*src\s*=\s*('|")index\.js\1[^>]*>\s*<\/\s*script\s*>/g));
Challenge Seed
<html>
<body>
<!-- add your code below -->
<!-- add your code above -->
</body>
</html>
Solution
<html>
<body>
<!-- add your code below -->
<script type="module" src="index.js"></script>
<!-- add your code above -->
</body>
</html>