1.安装query
npm install jquery --save
或
在package.json
中指定版本号,然后运行npm install
命令
"dependencies": {
"jquery": "^3.4.1"
}
npm install
2. 配置vue.config.js
在 vue.config.js
中
const webpack = require('webpack')
module.exports = {
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"windows.jQuery": "jquery"
})
]
}
}
3. 配置 $
在 main.ts
或 main.js
中配置
import $ from 'jquery'
Vue.prototype.$ = $
此生入这华夏,我是半点未曾后悔过