所以Bootstrap 4 Beta
已經出來了...... yey!然而Tether已被Popper.js
替代爲工具提示(和其他功能)。我看到控制檯足夠快拋出一個錯誤告訴我的變化對Popper.js
:Bootstrap 4 Beta用Webpack 3.x導入Popper.js拋出Popper不是構造函數
Bootstrap dropdown require Popper.js
似乎很容易,我去了,更新了我的webpack.config.js
(整個配置可以看出here)和Bootstrap然後開始工作(我做的唯一的變化是與波普爾更換特瑟):
plugins: [
new ProvidePlugin({
'Promise': 'bluebird',
'$': 'jquery',
'jQuery': 'jquery',
'window.jQuery': 'jquery',
'window.$': 'jquery',
Popper: 'popper.js'
}),
我也在我main.ts
文件做了import 'bootstrap'
。
不過,我現在有一個問題(我沒有帶繫繩有),一個新的錯誤被扔在控制檯:
Uncaught TypeError: Popper is not a constructor
如果我嘗試在Chrome中進行調試,我有Popper
加載一個對象(這就是Bootstrap停止抱怨的原因),你可以在下面的打印屏幕中看到。
最後包含我所有的代碼。我使用的引導提示與Aurelia
和TypeScript
(使用了與以前的引導阿爾法6和繫繩工作)
import {inject, customAttribute} from 'aurelia-framework';
import * as $ from 'jquery';
@customAttribute('bootstrap-tooltip')
@inject(Element)
export class BootstrapTooltip {
element: HTMLElement;
constructor(element: HTMLElement) {
this.element = element;
}
bind() {
$(this.element).tooltip();
}
unbind() {
$(this.element).tooltip('dispose');
}
}
貌似我沒有導入Popper
正確的,如果是這樣那麼什麼是最好建立了一個簡單的自定義元素用Webpack 3.x
實現那種方式?
真棒!我在3天前在網上尋找它!非常感謝!!! – LeandroLuk
嘿傢伙!我如何使用aurelia.json做同樣的事情? –
@JhonatasKleinkauff這裏的問題只針對WebPack,但對於'Aurelia-CLI',你是否嘗試過沿着前面Tether導入的一行:[aurelia-cli-to-use-with-bootstrap-4](https: //sackoverflow.com/questions/39432962/how-to-add-tether-in-aurelia-cli-to-use-with-aootlia-cli-to-use-with-bootstrap-4/39461325#39461325) – ghiscoding