gpt4 book ai didi

javascript - Visual Studio typescript "Uncaught ReferenceError: exports is not defined at...."

转载 作者:太空狗 更新时间:2023-10-29 15:43:52 26 4
gpt4 key购买 nike

<分区>

我正在使用 visual studio 学习 typeScript,并尝试进行简单的类导出。我已经多次看到这个问题,但没有一个解决方案对我有帮助。我做错了什么?

  • 我已经将模块系统从 CommonJs 更改为 system
  • 我已经安装了 npm systemJs
  • 尝试将“导入”写成“///...引用路径..../”

还是一样的错误“Uncaught ReferenceError: exports is not defined at...”

import { Address } from "./address";

class Customer {
protected name: string = "";
public addressObj: Address = new Address();
private _CustomerName: string = "";
public set CustomerName(value: string) {
if (value.length == 0) {
throw "Customer name is requaierd"
}
this._CustomerName = value;
}
public get CustomerName(): string {
return this._CustomerName;
}
}
export class Address {
public street1: string = "";
}
<!doctype html>
<html>

<head>
<title></title>
<meta charset="utf-8" />
</head>

<body>
<script src="address.js"></script>
<script src="Customer.js"></script>
<script>
try {
cust = new Customer();
cust.CustomerName = "doron";
cust.addressObj.street1 = "test"
} catch (ex) {
alert(ex);
}
</script>
</body>

</html>

我还有什么没做的?!?!

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com