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了。

相关推荐
tryCbest1 小时前
Vue系列——第 15 篇:内置组件全家桶——Transition、Teleport、Suspense、KeepAlive
前端·vue.js
徐小夕6 小时前
开源Vector-Graph-RAG:向量+图谱双引擎,打破纯向量RAG的效果天花板
前端·vue.js·github
FungLeo9 小时前
成为全栈·Vue 管理后台篇·Vue3 + Vite + Naive UI:后台工程基座怎么搭
前端·vue.js·ui·typescript·vite·前端工程化·biome
FungLeo9 小时前
成为全栈·Vue管理后台篇·<scriptsetup>:把页面拆成可读、可测的 Vue 组件
前端·javascript·vue.js·typescript·前端组件化·composition api·vue sfc
软件技术NINI1 天前
基于SpringBoot和Vue的新能源汽车销售推荐系统
java·vue.js·spring boot·后端·汽车·毕业设计·毕设
招风的黑耳1 天前
SpringBoot+Vue+MySQL 民宿在线预定平台 完整可运行版(源码+文档)
vue.js·spring boot·mysql
10share2 天前
基于大模型的 i18n 方案:把中文原文当 Key,轻松搞定多语言维护
前端·vue.js
啾咪orJIUMI2 天前
Vue 3 + 高德地图封装实战:点位、区域、Loca 流光与 Vue 信息窗体
前端·vue.js
FRing032 天前
vue2干货总结8(路由模块封装、router-link、声明式导航、路由重定向、编程式导航)
开发语言·前端·vue.js·vue2
无懈可击2 天前
Vue 可视化AI表单设计器 FcDesigner v3.6 版本发布,支持导出 SQL功能!
vue.js·开源·ai编程