vue(1)-安装

目录

1.1 npm安装(即安装nodejs)

1.2 npm-镜像

1.3 VUE安装

1.4 新建项目

1.5 打包发布

1.6 依赖包更新

1.7 Yarn 安装

1.8 相关组件

1.9 VS Code 插件


​​​​​​​

1.1 npm安装(即安装nodejs)

vue(1)-安装

NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题.

由于新版的nodejs已经集成了npm,所以之前npm也一并安装好了.

验证:

node –v

npm  –v

 

1.2 npm-镜像

npm config set registry https://registry.npm.taobao.org --global

npm config set disturl https://npm.taobao.org/dist --global

验证:

npm config get registry 

也可使用cnpm

npm install cnpm -g --registry=https://registry.npm.taobao.org

以后的npm可有cnpm代替

 

1.3 VUE安装

npm install --global vue-cli

验证:

npm vue -v

 

1.4 新建项目

  • 首先,创建,进入项目目录
vue init webpack my-project

 

  vue(1)-安装

 

 进入项目,安装并运行:

npm install
npm run dev

效果:

vue(1)-安装

 

 

 

这是package.json中出现要依赖的组件(package.json里面声明依赖后 直接使用npm install 安装(当前目录)。后面要安装依赖)。package.json:

{

  "name": "my-project",

  "version": "1.0.0",

  "description": "A Vue.js project",

  "author": "steven",

  "private": true,

  "scripts": {

    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",

    "start": "npm run dev",

    "build": "node build/build.js"

  },

  "dependencies": {

    "vue": "^2.5.2",

    "vue-router": "^3.0.1"

  },

  "devDependencies": {

    "autoprefixer": "^7.1.2",

    "babel-core": "^6.22.1",

    "babel-loader": "^7.1.1",

    "babel-plugin-transform-runtime": "^6.22.0",

    "babel-preset-env": "^1.3.2",

    "babel-preset-stage-2": "^6.22.0",

    "babel-register": "^6.22.0",

    "chalk": "^2.0.1",

    "copy-webpack-plugin": "^4.0.1",

    "css-loader": "^0.28.0",

    "eventsource-polyfill": "^0.9.6",

    "extract-text-webpack-plugin": "^3.0.0",

    "file-loader": "^1.1.4",

    "friendly-errors-webpack-plugin": "^1.6.1",

    "html-webpack-plugin": "^2.30.1",

    "webpack-bundle-analyzer": "^2.9.0",

    "node-notifier": "^5.1.2",

    "postcss-import": "^11.0.0",

    "postcss-loader": "^2.0.8",

    "semver": "^5.3.0",

    "shelljs": "^0.7.6",

    "optimize-css-assets-webpack-plugin": "^3.2.0",

    "ora": "^1.2.0",

    "rimraf": "^2.6.0",

    "url-loader": "^0.5.8",

    "vue-loader": "^13.3.0",

    "vue-style-loader": "^3.0.1",

    "vue-template-compiler": "^2.5.2",

    "portfinder": "^1.0.13",

    "webpack": "^3.6.0",

    "webpack-dev-server": "^2.9.1",

    "webpack-merge": "^4.1.0"

  },

  "engines": {

    "node": ">= 4.0.0",

    "npm": ">= 3.0.0"

  },

  "browserslist": [

    "> 1%",

    "last 2 versions",

    "not ie <= 8"

  ]

}

 

 

1.5 打包发布

$ cd my-project

$ npm run build


 项目下会产生一个dist文件,放入tomcat即可发布。

 

1.6 依赖包更新

npm install  再次即可

 

​​​​​​​1.7 Yarn 安装

   也可用yarn安装

Yarn install 略

 

1.8 相关组件

  •     Element          用于web开发
  •     Vant 、MINT  用于手机端开发

 

 

 

1.9 VS Code 插件

vue(1)-安装

具体使用:https://www.cnblogs.com/axl234/p/7690874.html