我有一个问题,我无法使用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() {
}
}
感谢您的帮助