1、安装
yarn add jquery -S
2、webpack.config.js
let webpack = require('webpack');
module.exports = {
plugins: [
...
new webpack.ProvidePlugin({
$: 'jquery', // jquery把$暴露出来
jquery: 'jquery'
})
],
}
ok
本文介绍如何使用Yarn包管理器安装jQuery,并通过Webpack配置实现jQuery的全局引入,确保在项目中可以无缝使用jQuery的功能。
1、安装
yarn add jquery -S
2、webpack.config.js
let webpack = require('webpack');
module.exports = {
plugins: [
...
new webpack.ProvidePlugin({
$: 'jquery', // jquery把$暴露出来
jquery: 'jquery'
})
],
}
ok
1688

被折叠的 条评论
为什么被折叠?