javascript - 在 Vue.js 中包含 bootstrap 抛出 jQuery not found 错误

标签 javascript google-chrome-extension webpack vue.js gulp

我正在使用 Vue.js 编写一个 chrome 扩展,对于我需要引导的界面。我添加了如下所示的 Bootstrap ,但它抛出错误 Uncaught ReferenceError: jQuery is not Defined 在 Object.dismiss (popup.js:9113)

import jQuery from 'jquery';
import bootstrap from 'bootstrap';
import Vue from 'vue';
import App from '../component/app.vue';

var app=new Vue({
  el:'#app',
  data:{
    name:'vue-chrome-extension'
},
render: h =>h(App)
})

我该如何修复这个错误?

最佳答案

 - First Upoll Install the Jquery Npm Package via this command where ur
   project is situated .

   open the command prompt >> enter the following Command.

   **cd "your Project folder path"**   then Press enter  Then  Type the following command to install the Jquery package in ur project. As

    @TremendusApps suggests in his answer, add the Expose Loader
   package:

   npm install expose-loader --save-dev

   import in your entry point main.js like this:

   import 'expose?$!expose?jQuery!jquery'


   Or 

   Add the ProvidePlugin to the plugins array in both
   build/webpack.dev.conf.js and build/webpack.prod.conf.js so that
   jQuery becomes globally available to all your modules:

   plugins: [
     new webpack.ProvidePlugin({
       $: 'jquery',
       jquery: 'jquery',
       'window.jQuery': 'jquery',
       jQuery: 'jquery'   }) 
            ]

Regards.

关于javascript - 在 Vue.js 中包含 bootstrap 抛出 jQuery not found 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47592779/

相关文章:

javascript - 将单词组合成单词数组

javascript - Chrome 扩展程序内容脚本中的 polymer 元素

javascript - Webpack 解析导入路径的目录(goCardless 作为样板)

javascript - 无法以 Angular 找到 CSS

javascript - PHP 和 AJAX 内部 500 错误

javascript - Google Chrome 插件开发 - 监控网络请求?

javascript - 如何检测和/或阻止破坏我网站的浏览器扩展?

javascript - 为什么webpack找不到loader

javascript - 具有未封闭 block 的引导依赖性错误

javascript - 函数触发 10 次后如何实现clearTiimeout?模拟掷骰子