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

2023-12-14 05:14:33

在这里插入图片描述

第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 配置

"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配置

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了。
在这里插入图片描述

文章来源:https://blog.csdn.net/cuclife/article/details/134913395
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。