1.新建一个目录
2.初始化一个工程
vue init webpack myvue
3.进入项目:
cd myvue
4.安装:npm install
5.启动项目:npm run dev
6.运行完成:
7.打开网页:http://localhost:8080/
8.idea 跑一下
安装webpack:
npm install webpack -g
npm install webpack-cli -g
webpack的使用:
新建一个项目:
hello.js
//暴露一个方法
exports.sayhi=function () {
document.write("<h1>moon</h1>")
}
main.js
var hello=require("./hello")
hello.sayhi();
webpac.config.js:
module.exports={
entry:'./modules/main.js',
output:{
filename:"./js/bundle.js"
},
mode:"development"
}
module.exports={
entry:'./modules/main.js',
output:{
filename:"./js/bundle.js"
},
mode:"development"
}
打包:
webpack
运行:
http://localhost:63342/webpackstudy/?_ijt=v0h36dr81kicsln0fqf94jtk66
router:
安装:
npm install vue-router --save-dev