A. Installation depends
npm install jquery --save
II. Global introduced (must be installed dependent)
first step
In webpack.base.conf.js
was added (the new version may not find this file, you can npm install webpack --save-dev
manually install)
var webpack = require("webpack")
The second step
In module.exports
the last to join
plugins: [
new webpack.optimize.CommonsChunkPlugin('common.js'),
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery"
})
]
third step
In the main.js
introduction
import $ from 'jquery' //你做到这一步页面中你直接使用$就是jq了
新版
Directly main.js
introduced
import jquery from 'jquery' //你做到这一步页面中你直接使用$就是jq了
III. Vue individual components introduced (must be installed dependent)
Then a script component
<script>
import $ from "jquery" //其实嘛你安装依赖后你在node_modlules文件中的一个文件相对路径而已
console.log($) //你可以打印瞧瞧
</script>