gpt4 book ai didi

javascript - 无法在我的 angular-2 快速启动应用程序中加载 ng2-fullpage

转载 作者:行者123 更新时间:2023-11-29 19:06:41 25 4
gpt4 key购买 nike

我正在尝试使用整页 + angular2:

我无法加载要使用的 ng2-fullpage 包,以下是我的文件:

systemjs.config.js

(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',

// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// '@jquery':'npm:jquery/jquery.min.js',

// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'ng2-fullpage': 'npm:ng2-fullpage',
'jquery': 'npm:jquery/dist/jquery.js',
'fullpage.js': 'npm:fullpage.js/jquery.fullPage.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {HttpModule} from '@angular/http';
import {routing} from './app.routing';
import {NavbarComponent} from './components/navbar/navbar.component';
import { MnFullpageDirective, MnFullpageService } from 'ng2-fullpage/ng2-fullpage';

import { AppComponent } from './app.component';
import { ResumeComponent } from './components/resume/resume.component';
import { AboutComponent } from './components/about/about.component';
import {HomeComponent} from './components/home/home.component'



@NgModule({
imports: [ BrowserModule,HttpModule, routing ],
declarations: [ AppComponent, ResumeComponent, AboutComponent, HomeComponent, NavbarComponent,MnFullpageDirective],
bootstrap: [ AppComponent ],
providers: [MnFullpageService]
})
export class AppModule { }

对于 ng2-fullpage,我的 node_modules 文件夹结构如下所示:

enter image description here

我得到的错误是:

在我的网络选项卡中,当我点击 ng2-fullpage 时,我得到以下信息:

Cannot GET /node_modules/ng2-fullpage/ng2-fullpage

我一直在尝试使用 npm 页面上给出的 plunkr 解决这个问题,它似乎可以工作,但它对我不起作用。 plunkr 页面是

[ http://embed.plnkr.co/1p9zKp4CNI1HncAh1h9m][2]

控制台错误:

GET http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage 404 (Not Found)

"(SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage
Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:1190:29) [<root>]
at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:166:47) [<root> => <root>]
at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:416:38) [<root>]
Error loading http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage as "ng2-fullpage/ng2-fullpage" from http://localhost:3000/app/app.module.js"

最佳答案

修改您的 systemjs.config.js。改变这个:

'ng2-fullpage':               'npm:ng2-fullpage',

为此:

'ng2-fullpage':               'npm:ng2-fullpage/bundles/ng2-fullpage.bundle.js',

关于javascript - 无法在我的 angular-2 快速启动应用程序中加载 ng2-fullpage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42325399/

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