049:VUE 引入jquery的方法和配置


第049个

查看专栏目录: VUE ------ element UI

专栏目标

在vue和element UI联合技术栈的操控下,本专栏提供行之有效的源代码示例和信息点介绍,做到灵活运用。

(1)提供vue2的一些基本操作:安装、引用,模板使用,computed,watch,生命周期(beforeCreate,created,beforeMount,mounted, beforeUpdate,updated, beforeDestroy,destroyed,activated,deactivated,errorCaptured,components,)、 root , parent , children , slots , refs , props, emit , eventbus ,provide / inject, Vue.observable, listeners, attrs, nextTick , v-for, v-if, v-else,v-else-if,v-on,v-pre,v-cloak,v-once,v-model, v-html, v-text, keep-alive,slot-scope, filters, v-bind,.stop, .native, directives,mixin,render,国际化,Vue Router等 (2)提供element UI的经典操作:安装,引用,国际化,el-row,el-col,el-button,el-link,el-radio,el-checkbox ,el-input,el-select, el-cascader, el-input-number, el-switch,el-slider, el-time-picker, el-date-picker, el-upload, el-rate, el-color-picker, el-transfer, el-form, el-table, el-tree, el-pagination,el-badge,el-avatar,el-skeleton, el-empty, el-descriptions, el-result, el-statistic, el-alert, v-loading, message, alert, prompt, confirm , notify, el-breadcrumb, el-page-header,el-tabs ,el-dropdown,el-steps,el-dialog, el-tooltip, el-popover, el-popconfirm, el-card, el-carousel, el-collapse, el-timeline, el-divider, el-calendar, el-image, el-backtop,v-infinite-scroll, el-drawer等

本文章目录

应用场景

vue采用数据驱动,不对dom进行操作。 有的时候为了控制屏幕的宽高度等,需要引入jquery来进行处理。如何配置呢?

package.json 配置

javascript 复制代码
"dependencies": { 
  "axios": "^0.19.0", 
  "core-js": "^3.4.4", 
  "echarts": "^4.8.0", 
  "element-ui": "^2.13.0", 
  "jquery": "^3.4.1", 
  "ol": "^6.1.1", 
  "qs": "^6.9.4", 
  "screenfull": "^5.0.2", 
  "vue": "^2.6.10", 
  "vue-i18n": "^8.15.3", 
  "vue-router": "^3.1.3", 
  "vuex": "^3.1.2" 
}, 

vue.config.js配置

javascript 复制代码
const CopyWebpackPlugin = require('copy-webpack-plugin') 
const webpack = require('webpack') 
const path = require('path') 
const debug = process.env.NODE_ENV !== 'production' 
 
module.exports = { 
 
    configureWebpack: { 
 
        resolve: { 
            alias: { 
                'vue$': 'vue/dist/vue.esm.js', 
                '@': path.resolve('src') 
            } 
        }, 
        plugins: [ 
            new webpack.ProvidePlugin({ 
                $: "jquery", 
                jQuery: "jquery", 
                "windows.jQuery": "jquery" 
            }), 
        ], 
 
    }, 
 
    pluginOptions: { 
        'style-resources-loader': { 
            preProcessor: 'less', 
            patterns: [path.resolve(__dirname, "src/css/index.less")] 
        } 
    } 
} 

main.js配置

import $ from 'jquery'

配置完后就可以在项目中使用$l了。

相关推荐
q***38511 小时前
SpringBoot + vue 管理系统
vue.js·spring boot·后端
喵个咪1 小时前
go-kratos-admin 快速上手指南:从环境搭建到启动服务(Windows/macOS/Linux 通用)
vue.js·go
用户841794814562 小时前
vxe-gantt table 甘特图如何设置任务视图每一行的背景色
vue.js
小章鱼学前端2 小时前
2025 年最新 Fabric.js 实战:一个完整可上线的图片选区标注组件(含全部源码).
前端·vue.js
涔溪2 小时前
实现将 Vue3 项目作为子应用,通过无界(Wujie)微前端框架接入到 Vue2 主应用中(Vue2 为主应用,Vue3 为子应用)
vue.js·前端框架·wujie
源码技术栈5 小时前
什么是云门诊系统、云诊所系统?
java·vue.js·spring boot·源码·门诊·云门诊
lcc1875 小时前
Vue3 ref函数和reactive函数
前端·vue.js
艾小码5 小时前
还在为组件通信头疼?defineExpose让你彻底告别传值烦恼
前端·javascript·vue.js
带只拖鞋去流浪5 小时前
迎接2026,重新认识Vue CLI (v5.x)
前端·vue.js·webpack
Coder-coco5 小时前
游戏助手|游戏攻略|基于SprinBoot+vue的游戏攻略系统小程序(源码+数据库+文档)
java·vue.js·spring boot·游戏·小程序·论文·游戏助手