Vue项目搭建过程

 

环境搭建:mac+nodejs+npm

#安装node.js :                      $ brew install node   
#安装vue-cil:                       $ npm install -g vue-cli
注:
官网下载安装node.js:https://nodejs.org/en/
mac-使用brew安装软件

 

优化:

使用国内镜像提升下载速度:
    $ npm install -g cnpm --registry=https://registry.npm.taobao.org
    $ cnpm install -d
安装 nrm 自由切换 npm 源    $ cnpm install nrm
使用nrm:
    $ nrm ls 
    $ nrm use **

 

构建项目:

安装vue                $ npm install vue@2.1.6 
全局安装 vue-cli        $ npm install --global vue-cli 
创建新项目              $ vue init webpack my-project 
进入项目目录            $ cd my-project 
注:主要用的包都在package.json文件中
安装依赖 $ npm install
注:会发现多了一个node_modules目录,,里面就是项目依赖包资源 运行项目 $ npm run dev 打包项目       $ npm run build 测试打包项目:
  安装一个 http-server 服务 $npm install http-server -g
   使用:cd dist     http-server -p 3000

注意:

去掉打包时生成的 map 文件:/config/index.js 文件修改为:productionSourceMap: false


安装组件:

安装 vue 路由模块      $ npm install vue-router -D 
安装网络请求模块        $ npm install vue-router vue-resource --save
支持scss 文件预编译 
             $ npm install sass-loader -D
             $ npm install node-sass -D
支持jquery $
npm install --save jquery 安装一个ajax接口请求工具 $ npm install axios -D

 

posted @ 2017-10-17 15:58  简笔话_Golden  阅读(199)  评论(0编辑  收藏  举报