[英]Uncaught SyntaxError: in code compiled from Typescript
I used my Build Javascript code in an html file and I'm getting this error:我在 html 文件中使用了我的 Build Javascript 代码,但出现此错误:
Uncaught SyntaxError: The requested module './calculate.js' does not provide an export named 'calculate'
未捕获的语法错误:请求的模块“./calculate.js”不提供名为“calculate”的导出
Here is the Typescript.这是打字稿。 I don't know what I'm doing wrong.
我不知道我做错了什么。
class calculate{
public firstNumber:string;
public secondNumber:string;
public resultBox:string;
constructor() { }
greet(){
console.log("Hello my");
}
}
export {calculate};
Here is the JavaScript code:这是 JavaScript 代码:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class calculate {
constructor() { }
greet() {
console.log("Hello my");
}
}
exports.calculate = calculate;
Here is my HTML file:这是我的 HTML 文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
</body>
<script type="module">
import {calculate} from './calculate.js'
var cal= new calculate();
cal.greet();
</script>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.