淘宝镜像(官网:https://npm.taobao.org/)
npm install -g cnpm --registry=https://registry.npm.taobao.org
1,安装vue-cli
cnpm install vue-cli -g // 通过vue -V查看vue版本号
vue init webpack
Generate project in current directory? (Y/n) 在当前目录中生成项目(是)
Project name (admin)项目名称
Project description (A Vue.js project)项目描述
Author作者
Vue build (Use arrow keys)选则Runtime + Compiler: recommended for most users
Install vue-router? (Y/n)是否下载vue-router(是)
Use ESLint to lint your code? (Y/n)是否使用ESLint(否)
Set up unit tests (Y/n)是否设置单元测试(否)
Setup e2e tests with Nightwatch? (Y/n) 是否使用e2e(否)
Should we run `npm install` for you after the project has been created? (recommended) (Use arrow keys)项目创建后,我们应该为您运行“NPM安装(是)
npm run dev运行项目
4,安装axios
cnpm install axios --save
import axios from 'axios' 哪个文件需要用到就在哪个文件中引入
5,安装qs
npm install --save axios vue-axios qs
import qs from 'qs'qs 用来解决vue中post请求以 a=a&b=b 的格式(详情)
6,打包
由于直接打包不能正常预览,所以需要配置
在webpack.prod.conf.js中output添加参数publicPath:'./'
在utils.js中,找到return ExtractTextPlugin.extract( 在里面添加publicPath:'../../',以用来解决打包后图片路径的问题
网友评论