加载资源aurelia-event-aggregator失败(已正确安装)

时间:2019-02-17 11:40:55

标签: javascript aurelia-framework aurelia-event-aggregator

我正在按照一定的安排关注aurelia.io的联系人管理器教程。完成本教程后,sub / pub消息传递未完全正常运行(列表未得到更新),因此我得出结论,该程序无法识别publish / subscribe语句。在向他们添加警报消息以进行测试之后,我开始出现以下错误:

:44348/aurelia-event-aggregator.js:1 Failed to load resource: the server 
responded with a status of 404 ()
(SystemJS) XHR error (404) loading https://localhost:44348/aurelia-event- 
aggregator.js
  Error: XHR error (404) loading https://localhost:44348/aurelia-event- 
aggregator.js
Error loading https://localhost:44348/aurelia-event-aggregator.js as 
"aurelia-event-aggregator" from https://localhost:44348/employee-list.js

我已经尝试使用npm重新安装aurelia-event-aggregator(肯定安装正确)

employee-list.js

import { EmpAPI } from 'emp-api';
import { inject } from 'aurelia-framework';
import { EventAggregator } from 'aurelia-event-aggregator';
import { EmployeeUpdated } from 'employeeUpdated';
import { EmployeeViewed } from 'employeeViewed';

@inject(EmpAPI, EventAggregator)
export class EmployeeList {
    constructor(api, ea) {
        this.api = api;
        this.ea = ea;
        this.employees = [];

        ea.subscribe(EmployeeViewed, msg => this.select(msg.employee));
        ea.subscribe(EmployeeUpdated, msg => {
            let id = msg.employee.id;
            let found = this.employees.find(x => x.id == id);
            Object.assign(found, msg.employee);
        });
    }

    created() {
        this.api.getEmployeeList().then(employees => this.employees = employees);
    }

    select(employee) {
        this.selectedId = employee.id;
        return true;
    }
}

0 个答案:

没有答案