首页 文章

缺少Ng2-smart-table文件,404(未找到)

提问于
浏览
0

当我尝试在我的项目中实现ng2-smarttable时,它会出现以下错误:

http:// localhost:5555 / node_modules / ng2-smart-table / build / src / ng2-smart-table / lib.js无法加载资源:服务器响应状态为404(未找到)

这也适用于以下文件:

localhost /:56错误:(SystemJS)XHR错误(404 Not Found)loading http:// localhost:5555 / node_modules / ng2-smart-table / build / src / ng2-smart-table / lib.js(...) “在https://github.com/mgechev/angular2-seed/issues"(匿名函数)@(索引)报告此错误:56 http:// localhost:5555 / node_modules / ng2-smart-table / build / src /ng2-smart-table/ng2-smart-table.scss.js无法加载资源:服务器响应状态为404(未找到)http:// localhost:5555 / node_modules / ng2-smart-table / build /src/ng2-smart-table/ng2-smart-table.html.js无法加载资源:服务器响应状态为404(未找到)http:// localhost:5555 / node_modules / ng2-smart-table /build/src/ng2-smart-table/ng2-smart-table.scss.js无法加载资源:服务器响应状态为404(未找到)http:// localhost:5555 / node_modules / ng2-smart -table / build / src / ng2-smart-table / ng2-smart-table.html.js无法加载资源:服务器响应状态为404(未找到)http:// localhost:55 55 / node_modules / ng2-smart-table / build / src / ng2-smart-table / components / filter / filter.scss.js无法加载资源:服务器响应状态为404(未找到)http:// localhost:5555 / node_modules / ng2-smart-table / build / src / ng2-smart-table / components / cell / cell.scss.js无法加载资源:服务器响应状态为404(未找到)http: //localhost:5555/node_modules/ng2-smart-table/build/src/ng2-smart-table/components/pager/pager.scss.js无法加载资源:服务器响应状态为404(未找到) http:// localhost:5555 / node_modules / ng2-smart-table / build / src / ng2-smart-table / components / title / title.scss.js无法加载资源:服务器响应状态为404(不是发现)

我通过执行npm install --save ng2-smart-table安装了ng2-smart-table,之后,为了确保(也可能是不必要的)npm install .

我在我的模块中做了以下事情:

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { BrowserModule } from '@angular/platform-browser';

import { Ng2SmartTableModule } from 'ng2-smart-table';

import { SmartTableComponent } from './smart-table.component';

@NgModule({
    imports: [
        RouterModule,
        BrowserModule,
        Ng2SmartTableModule
    ],
    declarations: [SmartTableComponent],
    exports: [SmartTableComponent],
})

export class SmartTableModule { }

然后在组件中按照教程的说明进行必要的标准操作:https://akveo.github.io/ng2-smart-table/demo . 所以我做了:

import { Component, OnInit } from '@angular/core';

import { SensorData } from '../tables/sensor-data';
import { SensorDataService } from '../tables/sensor-data.service';

import { LocalDataSource } from 'ng2-smart-table';

// webpack html imports

@Component({
    moduleId: module.id,
    selector: 'smart-table',
    templateUrl: 'smart-table.component.html'
})

export class SmartTableComponent {

    settings = {
        columns: {
            SendDate: {
                title: 'Send Date'
            },
            Key: {
                title: 'Key'
            },
            Value: {
                title: 'Value'
            },
            SensorId: {
                title: 'Sensor #Id'
            }
        }
    };

    source: LocalDataSource;

    public constructor(private sensorDataService: SensorDataService) {
        this.source = new LocalDataSource();

        this.sensorDataService.getSensorData(2)
            .subscribe(
            data => {
                this.source.load(data);
                console.log(this.source);
            },
            error => console.log(<any>error));
    }

}

我注意到它试图获得.js?我不明白我是如何解决这个问题的,因为我按照应有的方式做了一切 .

任何帮助将非常感激!

1 回答

  • 0

    我的项目有一个 systemjs.config.js 文件,用于映射和控制我的所有包 .

    请参阅下面的示例:

    var packages = {
        'angular2-highcharts': {main: 'index.js', defaultExtension: 'js' }
    };
    

    这个 defaultExtension 可能会阻碍你 .

相关问题