我想把我的主机装满。tsfile并在它完全加载后,初始化我正在使用的其他文件作为 singleton。
使用console.log()
时,我注意到我的singletonExample。ts文件在main之前运行。ts,我可以操纵流使main。ts*在任何其他ts或js文件 * 之前运行?
我的示例文件包含typescript类。
代码示例
main.ts
console.log('main');
singletonExample.ts
console.log("single");
//控制台结果
single
main
1条答案
按热度按时间imzjd6km1#
将
singletonExample.ts
导入main.ts
作为其第一行那么
main.ts
总是在singletonExample.ts
之前执行