当我将我的'app.js'文件链接到HTML时,出现一条错误消息:Uncaught ReferenceError: exports is not defined
。
所以我在项目中添加了 systemjs 。最终像这样在我的浏览器控制台中。
Uncaught Error: Unable to resolve bare specifier
经过多次搜索,我发现最新版本的systemjs在TypeScript中存在一些错误。在降级为 systemjs 版本0.20.18(或 systemjs 2.0以下的任何旧版本)之后,我收到了新的错误消息:
Uncaught (in promise) Error: Fetch error: 404 Not Found at system.js:4
我搜索了很多主题,找不到任何解决方案。我当前的HTML如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Shopping cart</title>
<meta name="description" content="************">
<meta name="keyword" content="************">
<link rel="stylesheet" type="text/css"
href="fonts/FontAwesome/css/font-awesome.min.css"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,700,700i&subset=vietnamese"
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<header id="main-header" class="mbpc-30 mbsp-15">
<div class="top-bar"></div>
<div class="bottom-bar"></div>
</header>
<main class="page-index" role="main">
<!-- Content here -->
</main>
<footer id="main-footer">
</footer>
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/function/system.js"></script>
<script>
System.import('js/function/app.js');
</script>
<script type="text/javascript" src="js/setting.js"></script>
</body>
</html>