我在Angular 2中使用SystemJS作为模块系统。这是我的index.html
文件
<html>
<head>
<base href="/">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>Home</title>
<link rel="stylesheet" href="//js.arcgis.com/3.15/esri/css/esri.css">
<!-- IE required polyfills, in this exact order -->
<script src="es6-shim/es6-shim.min.js"></script>
<script src="systemjs/dist/system-polyfills.js"></script>
<script src="angular2/bundles/angular2-polyfills.js"></script>
<script src="systemjs/dist/system.src.js"></script>
<script src="rxjs/bundles/Rx.js"></script>
<script src="angular2/bundles/angular2.dev.js"></script>
<!-- Routing -->
<script src="angular2/bundles/router.dev.js"></script>
<!-- ArcGIS -->
<script src="//js.arcgis.com/3.15/"></script>
<script>
System.config({
defaultJSExtensions: true,
map: {
esri: '//js.arcgis.com/3.15/esri'
},
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/main')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<app>Loading map...</app>
</body>
</html>
不幸的是我收到以下错误:
出现此错误是因为我使用的是SystemJ而不是AMD,因此无法正确识别定义。你有什么建议吗?
编辑:
添加了以下配置:
<script>
System.config({
defaultJSExtensions: true,
packages: {
app: {
format: 'register',
defaultExtension: 'js',
map: {
esri: '//js.arcgis.com/3.15/esri'
},
meta: {
'esri/*': {
format: 'amd'
}
}
}
}
});
System.import('app/main')
.then(null, console.error.bind(console));
</script>
但仍然得到相同的错误