美文网首页
vue中引入jquery

vue中引入jquery

作者: monkeyfly36 | 来源:发表于2019-01-15 15:30 被阅读0次
    1. npm install jquery --save
    dependencies:{
      "jquery":"^2.2.1"
    }
    

    2.在webpack.base.conf.js中加入一行代码
    var webpack=require("webpack")

     var webpack = require('webpack')
     'use strict'
     const path = require('path')
     const utils = require('./utils')
     const config = require('../config')
     const vueLoaderConfig = require('./vue-loader.conf')
    

    在webpack.base.conf.js中module.exports的最后加入这行代码,

      plugins: [
      new webpack.optimize.CommonsChunkPlugin('common.js'),
      new webpack.ProvidePlugin({
        jQuery: "jquery",
        $: "jquery"
      })
        ],
      resolve: {
        extensions: ['.js', '.vue', '.json'],
        alias: {
          'vue$': 'vue/dist/vue.esm.js',
          '@': resolve('src'),
        }
      },
    

    3.在main.js中引入,加入下面这行代码,全局引入

    import $ from 'jquery'
    

    参考地址:https://www.cnblogs.com/eyed/p/7850946.html

    相关文章

      网友评论

          本文标题:vue中引入jquery

          本文链接:https://www.haomeiwen.com/subject/wpgddqtx.html