vue中引用jQuery

1.npm install jquery –save ( npm install jquery)

2.webpack.config.js 中添加

resolve: {
alias: {

  'vue$': 'vue/dist/vue.esm.js',
  'jquery':'jquery'
}

},

plugins中添加如下:
new webpack.ProvidePlugin({
$: “jquery”,
jQuery: “jquery”
}),

3.main.js 中導入jQuery

import jquery from “jquery/tmp/jquery.js”(添加此行代碼是看一下jQuery 路徑)

4.app.vue 中導入jquery

import $ from “jquery”;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章