2017-12-01 6 views
0

ブートストラップが必要なインターフェース用にVue.jsを使用してクロム拡張機能を作成しています。私は、次のようにブートストラップを追加しましたが、それは私はこのエラーを修正する方法をUncaught ReferenceError: jQuery is not defined at Object.dismiss (popup.js:9113)Vue.jsにブートストラップを含めるとjQueryが見つかりません。エラー

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) 
}) 

エラーを投げますか?

+0

window.jQueryオブジェクトを設定してみ?輸入が正しく指示されていることを確認しましたか? –

+0

@YorkiBonilla - 私はVue.jsを初めて使っています。 npmコマンドを使用してブートストラップをインストールし、 'bootstrap 'からのインポートブートストラップを使用してインポートしました; – Unnikrishnan

答えて

1
- 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. 
+0

' npm install expose-loader --save-dev'と 'import' expose?jQuery!ありがとう! – Unnikrishnan

+0

いつでも歓迎します:) – DotNet

0

は、あなたが何をしようとしたグローバル

window.jQuery = jQuery; 
関連する問題