如何使用webpack导入angular2中的旧js node_modules文件

时间:2016-07-12 16:19:15

标签: javascript import angular webpack node-modules

我有一个问题,我无法使用Bootstrap在Angular2中导入BootstrapMenu当我想用Webpack导入.js文件时遇到了困难。

我在控制台中收到此错误:

Cannot find name 'BootstrapMenu'

我尝试像这样导入BootStrapMenu:

import '../../../node_modules/bootstrap-menu/dist/BootstrapMenu.min.js';

这是我的组成部分:

import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import '../../../node_modules/bootstrap-menu/dist/BootstrapMenu.min.js';

console.log('`Dashboard` component loaded asynchronously');

@Component({
    selector: 'dashboard',
    templateUrl: 'dashboard.component.html'
})

export class Dashboard {
    localState;

    constructor(public route: ActivatedRoute) {

    }

    ngOnInit() {
        this.route
            .data
            .subscribe((data: any) => {
                this.localState = data.yourData;


     });
            console.log('hello `Dashboard` component');


            var menu = new BootstrapMenu('.line', {
                .....
                .......
                }
        });

    }
    asyncDataWithWebpack() {

    }
}

感谢您的帮助

0 个答案:

没有答案