本文介绍了< script type = text/javaScript>与< script type = module>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用< script type = text/javascript> < script type = module> 加载HTML中的JavaScript文件有什么区别?

What is the difference between loading JavaScript files in HTML using <script type=text/javascript> and <script type=module>?

推荐答案

HTML5规范不鼓励使用 type = text/javascript :

The HTML5 specification discourages the use of type=text/javascript:

来自 https://www.w3.org/TR/html5/semantics-scripting.html#element-attrdef-script-type :

将属性设置为字符串"module"的ASCII不区分大小写的匹配项.表示该脚本是模块脚本,将根据JavaScript Module顶级产品进行解释.模块脚本不受字符集和延迟属性的影响.

Setting the attribute to an ASCII case-insensitive match for the string "module" means that the script is a module script, to be interpreted according to the JavaScript Module top-level production. Module scripts are not affected by the charset and defer attributes.

(我强调)

这篇关于&lt; script type = text/javaScript&gt;与&lt; script type = module&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 20:53
查看更多