当前位置:网站首页>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 .
边栏推荐
- Benji Bananas 开启第二季边玩边赚奖励活动,支持使用多张 Benji 通行证!
- Embedded general learning route arrangement
- Mba-day28 concept of number - exercise questions
- 二叉排序树(BST) ~
- ament_cmake生成ROS2库并链接
- 二叉树的前中后序遍历——本质(每个节点都是“根”节点)
- Chapter 1 - Construction of development environment
- Learn about spark project on nebulagraph
- idea yml 文件代码不提示解决方案
- Detailed explanation of the whole process of coding's pressure measurement operation
猜你喜欢

Rocbossphp free open source light community system

Ros2 preliminary: basic communication with topic

MBA-day29 算术-绝对值初步认识

Modifiers should be declared in the correct order 修饰符应按正确的顺序声明

The refurbishment and counterfeiting of chips have made people feel numb

Introduction to Chinese text error correction task

Development projects get twice the result with half the effort, a large collection of open source STM32 driver Libraries

二叉树的前中后序遍历——本质(每个节点都是“根”节点)

【Oracle SQL】计算同比与环比(列转行进行偏移)

Mba-day29 arithmetic - preliminary understanding of absolute value
随机推荐
leetcode-Array
Establishment of log collection and analysis platform-1-environment preparation
秋招-准备计划
Redis official visualization tool, with high appearance value and powerful functions!
5-year-old Test Engineer - how to choose the next step?
招标信息获取
JS的调用方式与执行顺序
Redis master-slave replication
Autumn move - Preparation Plan
Use of feign (Part 2)
Ros2 preliminary: basic communication with topic
Solve vagrant's error b:48:in `join ': incompatible character encodings: GBK and UTF-8 (encoding:: Compatib
Ros2 knowledge: DDS basic knowledge
The refurbishment and counterfeiting of chips have made people feel numb
卸载手机自带APP的操作步骤
Kingbasees SQL language reference manual of Jincang database (6. Expression)
Lightweight MCU command line interaction project, all open source
满二叉树 / 真二叉树 / 完全二叉树 ~
Redis持久化-RDB
Talking about the practice of software defect management