【问题标题】:Unable to Import 'Multiselect-Dropdown' Package in Angular2 App无法在 Angular2 应用程序中导入“Multiselect-Dropdown”包
【发布时间】:2017-01-06 08:27:12
【问题描述】:

我在 Angular2 应用程序中使用 multiselect-dropdown 并导入包,如:

import {MultiselectDropdown, IMultiSelectOption} from './multiselect-dropdown';
@Component({
directives: [MultiselectDropdown]
});

但是在运行应用程序时,我得到了错误:

SyntaxError: Unexpected token : 在 ZoneDelegate.invoke (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:349:29) 在 Zone.run (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:242:44) 在http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:597:58 评估http://localhost:3000/app/multiselect-dropdown.tshttp://localhost:3000/app/boot.tsZoneDelegate.invoke@angular2-polyfills.js:349Zone.run@angular2-polyfills.js:242(匿名函数)@angular2-polyfills.js:597ZoneDelegate.invokeTask@将http://localhost:3000/app/multiselect-dropdown.ts加载为“./multiselect-dropdown”时出错angular2-polyfills.js:382Zone.runTask @ angular2-polyfills.js:282drainMicroTaskQueue @ angular2-polyfills.js:500ZoneTask.invoke @ angular2-polyfills.js:452 content_script.js:2 http://localhost:3000/app/boot.ts

我正在使用的包是:https://github.com/softsimon/angular-2-dropdown-multiselect

【问题讨论】:

    标签: angular


    【解决方案1】:

    如下更改您的导入语句:

    import {MultiselectDropdown, IMultiSelectOption} from 'multiselect-dropdown';
    

    【讨论】:

    • 从 './multiselect-dropdown' 导入 {MultiselectDropdown, IMultiSelectOption};是 multiselect-dropdown.ts 文件的路径及其正确。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-11
    • 1970-01-01
    • 2021-03-26
    相关资源
    最近更新 更多