当前位置:网站首页>Namespace in TS (2)
Namespace in TS (2)
2022-06-13 08:26:00 【aliven1】
References between multiple namespaces
- Components Namespace
namespace Components{
export class Header {
constructor() {
const ele = document.createElement('div')
ele.innerHTML = "This is Header"
document.body.appendChild(ele)
}
}
export class Content {
constructor() {
const ele = document.createElement('div')
ele.innerHTML = "This is Content"
document.body.appendChild(ele)
}
}
export class Footer {
constructor() {
const ele = document.createElement('div')
ele.innerHTML = "This is Footer"
document.body.appendChild(ele)
}
}
}
Page Namespace
namespace Home {
// Namespace
export class Page {
constructor() {
new Components.Header()
new Components.Content()
new Components.Footer()
}
}
}
- tsc After the compilation ,html The use of :script Introduce multiple js file
After introducing the file , Put the exposed namespace into the global , Named empty exposed classes , For use
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./dist/components.js"></script>
<script src="./dist/page.js"></script>
</head>
<body>
<script> new Home.Page() </script>
</body>
</html>
边栏推荐
- File upload question type
- Document contains question type
- Notes on MySQL transaction not automatically submitting
- JS - simple ATM of the for cycle case
- Dest0g3 520 orientation
- SQL injection experiment
- Verify the word limit of textarea input box. Only prompt but no submission limit
- Homestead environment setup
- 字符串的逆序与比较
- How to hide tabs in nailing applet
猜你喜欢

HCIP_ Static experiment

How can the small and medium-sized lighting industry make use of the digital transformation to stand out from the encirclement?

微服务项目搭建三:自动生成代码

How to install the bdtab (BD) new tab plug-in in edge browser (Graphic tutorial)

SQL injection experiment

Buuctf web (V)

JS - max. of array cases

Create a substrate private network

Shellshock Attack Lab

Microservice system architecture construction I: Environment Construction
随机推荐
The method of SolidWorks modifying text font in engineering drawing
Logstash failed to create queue
HCIP_ MGRE experiment
Edge浏览器如何安装BdTab(BD)新标签页插件(图文教程)
[game theory complete information static game] Nash equilibrium
DNS domain name resolution service
How can the small and medium-sized lighting industry make use of the digital transformation to stand out from the encirclement?
How to download and install stm32cubemx
Cosmos star module development
Batch package and download Alibaba OSS files
CCNP_ Summary (Continued)
ERP基础数据 金蝶
JS - for cycle case: Horse grain
Numeric types in SQL. Try to avoid using null as the default value
Notes on development experience: TP5 exp query, SQL analysis, JQ, applet, right-click menu, Linux skills, shell skills, mysql, etc
ERP basic data Huaxia
Data accuracy problems caused by inconsistent data types during sum in MySQL
LeetCode-按奇偶排序数组
Methods of importing and exporting settings in Altium Designer
Homestead environment setup