通过Webpack进行Vue CLI和Bootstrap

问题描述 投票:0回答:1

我正在尝试使用Vue CLI来启动引导程序。我安装了jQuery和Bootstrap,如下所示:

npm install jquery bootstrap

然后像这样配置webpack:

  module.exports = {
    plugins: [
      new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "window.jQuery": "jquery",
        tether: 'tether',
        Tether: 'tether',
        'window.Tether': 'tether',
        Alert: "exports-loader?Alert!bootstrap/js/dist/alert",
        Button: "exports-loader?Button!bootstrap/js/dist/button",
        Carousel: "exports-loader?Carousel!bootstrap/js/dist/carousel",
        Collapse: "exports-loader?Collapse!bootstrap/js/dist/collapse",
        Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
        Modal: "exports-loader?Modal!bootstrap/js/dist/modal",
        Popover: "exports-loader?Popover!bootstrap/js/dist/popover",
        Scrollspy: "exports-loader?Scrollspy!bootstrap/js/dist/scrollspy",
        Tab: "exports-loader?Tab!bootstrap/js/dist/tab",
        Tooltip: "exports-loader?Tooltip!bootstrap/js/dist/tooltip",
        Util: "exports-loader?Util!bootstrap/js/dist/util",
      })
    ],
  }

虽然没有快乐。即使使用jQuery。

我正在寻找一个webpack解决方案。

谢谢,杰米

twitter-bootstrap webpack vue-cli
1个回答
0
投票

在你的main.jsapp.js中,无论你使用哪个主要的Javascript文件,添加以下内容:

import 'bootstrap'
window.$ = window.jQuery = require('jquery')
© www.soinside.com 2019 - 2024. All rights reserved.