vue常用姿势

1、利用脚手架安装项目

  npm install -g vue-cli      (-g表示全局安装, vue-cli是模块,全局安装的模块可以在命令行直接使用. )

  vue init webpack  my-project

  cd my-project

  npm install

  npm run dev

2、vue常用网站

   https://vuefe.cn/v2/guide/installation.html   ------------------官网

 https://github.com/opendigg/awesome-github-vue   ---------相关开源项目库集合

3、常用插件的安装

  3.1安装sass

   npm install node-sass --save-dev

   npm install sass-loader --save-dev 

  3.2 安装mock.js

    npm install mockjs 

  3.3安装stylus

   npm install stylus-loader

   npm install stylus

4、npm install一直报错

在重新卸载node.js---安装重复此次操作几次后,发现仍然还是在报错

采用

4.1.如果有package-lock.json文件,删掉

4.2.管理员权限进入cmd

4.3.执行npm cache clean --force

4.4.之后再npm install,网不好的话采用npm install -g cnpm --registry=https://registry.npm.taobao.org

在手动卸载node.js的时候,可能会卸载不干净,需要C盘的Administrator---AppData---Roaming---npm和npm-cache删除干净

5、vue打包
  1、修改config下面的index.js       
    assetsPublicPath: '/' 改为 assetsPublicPath: './'                  productionSourceMap:true 改为productionSourceMap:false
   2、背景图片路径找不到
    更改 build/utils.js 文件中 ExtractTextPlugin 插件的options 配置(publicPath: '../../):
      

6、发现其他项目可以用本机IP访问,唯有vue-cli项目无法用本机IP访问

解决办法:将host重新定义为:0.0.0.0即可, 然后重启服务,发现localhost、127.0.0.1、本地IP均能正常访问,这样就可以用手机来预览效果啦

 

    
     

  

  

  

 

posted @ 2017-11-28 14:30  ljshu  阅读(186)  评论(0编辑  收藏  举报