gpt4 book ai didi

Angular2 rc4 Bootstrap

转载 作者:太空狗 更新时间:2023-10-29 19:35:32 26 4
gpt4 key购买 nike

我刚刚将我的 angular2 应用程序从 RC1 更新到 RC4。我完全按照指南进行操作,但由于某些奇怪的原因,我的 main.ts 文件中的应用程序引导无法正常工作。我的代码是:

import  { bootstrap } from '@angular/platform-browser-dynamic';

import { enableProdMode } from '@angular/core';

import { APP_ROUTER_PROVIDERS } from './service/routes.service';

import { AppComponent } from './components/app.component';

enableProdMode();

bootstrap(AppComponent, [
APP_ROUTER_PROVIDERS,
]);

我收到错误消息:

[ts] Module '"/Users/bradbeighton/Documents/Dev/coffeezan/node_modules/@angular/platform-browser-dynamic/index"' has no exported member 'bootstrap'. import bootstrap

"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "3.0.0-beta.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.4",

我安装的包与 Angular 建议的完全相同。所以我很困惑为什么找不到 Bootstrap 模块?

我还遇到了另一个问题,即按照他们在教程中建议的方式设置路由。

import { provideRouter, RouterConfig }  from '@angular/router';

import { HomeComponent } from '../components/home.component/home.component';';

const routes: RouterConfig = [
{ path: '/home', component: HomeComponent },
];

export const APP_ROUTER_PROVIDERS = [
provideRouter(routes)
];

不知道是我装傻了还是安装错了包?请帮助??

编辑:

我的 systemjs.config 文件非常标准,但它在这里:

var isPublic = typeof window != "undefined";

/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function(global) {
// map tells the System loader where to look for things
var map = {
'app': 'client', // 'dist',
'@angular': (isPublic)? '@angular' : 'node_modules/@angular',
'angular2-in-memory-web-api': (isPublic)? 'angular2-in-memory-web-api' : 'node_modules/angular2-in-memory-web-api',
'rxjs': (isPublic)? 'rxjs' : 'node_modules/rxjs',
'ng-semantic': (isPublic)? 'ng-semantic' : 'node_modules/ng-semantic'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'ng-semantic': { main: 'ng-semantic', defaultExtension: 'js' }
};
var ngPackageNames = [
'common',
'compiler',
'core',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade'
];
// Add package entries for angular packages
ngPackageNames.forEach(function(pkgName) {
packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
});
var config = {
map: map,
packages: packages
};
System.config(config);
})(this);

最佳答案

引用.umd.js 文件时,您需要使用bundles。请引用以下 block -

  function packUmd(pkgName) {
packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}

看看这是否有帮助。

关于Angular2 rc4 Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38283830/

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