当前位置:网站首页>Calling mode and execution sequence of JS
Calling mode and execution sequence of JS
2022-07-26 05:56:00 【Alkali!】
Usage mode
HTML Add... Anywhere on the page <script type="module"></script> Labels can be .
type="module" // Must add , This can strictly limit the scope of variables ,
Strictly limit each variable to its proper scope .
There are several common ways to use :
- Directly in
<script type="module"></script>The label says JS Code . - Import files directly :
<script type="module" src="/static/js/index.js"></script>. - Pass the required code through import Keyword is introduced into the current scope .
for example :/static/js/index.js The contents of the file are :
let name = "acwing";
function print() {
console.log("Hello World!");
}
export {
name,
print
}
<script type="module"></script> is :
<script type="module">
import {
name, print } from "/static/js/index.js";
console.log(name);
print();
</script>
Execution order
- Be similar to HTML And CSS, Press From top to bottom Sequential execution ;
- Event driven execution ;
HTML, CSS, JavaScript The relationship between the three
- CSS control HTML
- JavaScript control HTML And CSS
- In order to facilitate development and maintenance , Try to write code in the above order . for example : Not in HTML Call in JavaScript The function in .
边栏推荐
- idea yml 文件代码不提示解决方案
- Six sixths -- it's a little late and a little shallow
- How are masters refined?
- 招标信息获取
- em和rem
- The refurbishment and counterfeiting of chips have made people feel numb
- EM and REM
- 如何查看Pod里容器名称
- Using easyexcel to import tables to realize batch insertion of xlsx files ----- MySQL of Linux
- 为什么LPDDR不能完全代替DDR?
猜你喜欢

递归处理——子问题

2022 National latest fire-fighting facility operator (Senior fire-fighting facility operator) simulation test questions and answers

Redis事务

“子问题的递归处理”——判断两棵树是不是相同的树——以及 另一颗树的子树

递归函数中 有两个递归入口的时间复杂度

为什么LPDDR不能完全代替DDR?

【(SV && UVM) 笔试面试遇到的知识点】~ phase机制

Redis publish subscription

Redis发布订阅

1.12 basis of Web Development
随机推荐
L. Link with Level Editor I dp
Use latex to typeset multiple-choice test paper
Solution to slow download speed of vagrant
软件测试面试题全网独家没有之一的资深测试工程师面试题集锦
Use of feign (Part 2)
Six sixths -- it's a little late and a little shallow
某公司给每个工位装监控:只为看员工写代码?
Is it really hopeless to choose electronic engineering and be discouraged?
Should we test the Dao layer?
5-year-old Test Engineer - how to choose the next step?
Chapter 1 - Construction of development environment
Can you make a JS to get the verification code?
字节面试题——判断一棵树是否为平衡二叉树
[Oracle SQL] calculate year-on-year and month on month (column to row offset)
2022 National latest fire-fighting facility operator (Senior fire-fighting facility operator) simulation test questions and answers
[MySQL must know and know] time function number function string function condition judgment
知识沉淀一:架构师是做什么?解决了什么问题
二叉树的前中后序遍历——本质(每个节点都是“根”节点)
漫谈软件缺陷管理的实践
CANoe-XML在Test Modules中的应用