对上一节的代码使用了parcel,但似乎有问题

来源:4-11 使用 Parcel 打包 TS 代码

慕莱坞0998854

2020-02-13

按照老师的演示,对上节的代码做了修改,但是有点问题,在index.html里面,我写上

<script src="./src/page.ts"></script>
<script>
	new Page()
</script>

这样会报错,“Page is not defined”

我只能在page.ts里面,写成下面的形式.

	import {Header,Content,Footer} from "./components"
	class Page {
		constructor(){
			new Header()
			new Content()
			new Footer()
		}
	}

	new Page()

只有把new Page()写在这个位置才行,想问下为什么呢?

写回答

1回答

Dell

2020-02-15

parcel 解析的问题,你看下打包生成的代码,就知道问题了

0
0

专为小白设计的TypeScript入门课

Dell老师专为TypeScript小白打造的,全栈式教学TS入门课程

2249 学习 · 506 问题

查看课程