创建项目
1.全局安装 vue-cli
npm install vue-cli -g
2.创建项目
vue init webpack-simple vue.qmap
回车回车回车,创建成功
3.安装依赖包
cd vue.qmap //进入项目层
cnpm i //安装项目依赖包
4.运行项目
npm run dev
放入jquery
1.安装jquery
npm install jquery --save
2.webpack.config.js里配置
var webpack = require('webpack')
plugins:[
new webpack.ProvidePlugin({
jQuery:"jquery",
$:"jquery",
jquery:"jquery",
"window.jQuery":"jquery",
})
],
(注意:我把 webpack 放在最上面一行了)
3.main.js 里面全局引用
import $ from 'jquery'
4.页面里面调用
随便写个点击事件,执行成功。
methods:{
change(){
console.log(11);
$("#app").css("color","red");
}
}
安装jquery-ui
npm install jquery-ui-dist -S
npm i jquery jquery-ui
导入
import 'jquery-ui-dist/jquery-ui'
配置文件
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
jquery:'jquery',
}
},
// 添加代码
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
jquery: "jquery",
"window.jQuery": "jquery"
})
],