第049个
专栏目标
在vue和element UI联合技术栈的操控下,本专栏提供行之有效的源代码示例和信息点介绍,做到灵活运用。
应用场景
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配置
配置完后就可以在项目中使用$l了。