在HTML文件中包括JavaScript模块。 (香草JavaScript)
我有一个多文件网页,但是我只想要一个文件(index.html)。因为这似乎是使用Android WebView显示它的最简单方法。我有一个JavaScript文件JavaScript模块和HTML文件。
<!DOCTYPE html>
<html>
<body>
<script type="module">import * as Module from './Module.js';</script>
</body>
</html>
我知道如何在网页中包含普通脚本,但是如何将模块模块嵌入index.html中。
我想做这样的事情...
<!DOCTYPE html>
<html>
<body>
<script type="module" src="Module.js">
export function CallHello(){
console.log("Hello");
}
</script>
<script type="module">
import * as Module from './Module.js';
Module.CallHello();
</script>
</body>
</html>
I have a multi file webpage, but I just want one file (index.html). because this seems the easiest way to display it using android webview. I have a javascript file a javascript module and the html file.
<!DOCTYPE html>
<html>
<body>
<script type="module">import * as Module from './Module.js';</script>
</body>
</html>
I know how to include normal scripts in the webpage, but how do I embed the module Module.js in index.html.
I want to do something like this...
<!DOCTYPE html>
<html>
<body>
<script type="module" src="Module.js">
export function CallHello(){
console.log("Hello");
}
</script>
<script type="module">
import * as Module from './Module.js';
Module.CallHello();
</script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论