1. 安装jquery

  1. npm install jquery --save

2.在配置文件vue.config.js中添加jquery 配置

先引入webpack,然后配置jQuery.如下: 这里仅展示jquery相关的

  1. const webpack = require('webpack')
  2. module.exports = {
  3. publicPath: './',
  4. // 输出文件目录
  5. outputDir: 'dist',
  6. lintOnSave: true,
  7. configureWebpack: {
  8. plugins: [
  9. new webpack.ProvidePlugin({
  10. jQuery: 'jquery',
  11. $: 'jquery'
  12. })
  13. ]
  14. },
  15. //...
  16. }

3.使用

直接在文件中使用jQuery 或 $ 即可

  1. $('body').css("font-size", (12 * $(window).width() / 375) + "px")