vue中引用jQuery

来源:互联网 发布:sqlserver代理无法启动 编辑:程序博客网 时间:2024/06/05 18:04

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”;

0 0