我不使用webpack或browserify。我使用systemjs来加载模块。我的ASP.NET核心和放大器中有以下配置。 Angular2应用程序。
<environment names="Development">
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.41/system.js"></script>
<script src="~/lib/reflect-metadata/reflect.js"></script>
<script src="~/lib/zone.js/dist/zone.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script>
window.onload = () => {
System.defaultJSExtensions = true;
System.config({
map: {
'rxjs': "../../lib/rxjs/bundles/rx.js",
'@@angular/core': '../../lib/@@angular/core/bundles/core.umd.js',
'@@angular/common': '../../lib/@@angular/common/bundles/common.umd.js',
'@@angular/compiler': '../../lib/@@angular/compiler/bundles/compiler.umd.js',
'@@angular/platform-browser': '../../lib/@@angular/platform-browser/bundles/platform-browser.umd.js',
'@@angular/platform-browser-dynamic': '../../lib/@@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@@angular/http': '../../lib/@@angular/http/bundles/http.umd.js',
'@@angular/router': '../../lib/@@angular/router/bundles/router.umd.js',
'@@angular/forms': '../../lib/@@angular/forms/bundles/forms.umd.js',
}
});
System.import("../myapp/app.js");
}
</script>
</environment>
答案 0 :(得分:1)
答案是(1)“通过脚本标记在应用程序中全局加载zone.js”。 Zone.js执行拦截浏览器中所有异步API的关键任务,以创建角度变化检测所需的唯一执行上下文。它意味着在模块加载器开始引导角度应用程序之前包含它。