VUE-CLI process of building scaffolding

1, the installation node js

  Download: http://nodejs.cn/download/
2, run the installation is complete Node.js the Command prompt ( the Node -v view the installation version)

  
3, install npm (due to the current version has been integrated nodejs npm so no need to install, you can use npm -v  view version)

  
4, instead of registered CNPM npm
  use the command: npm the install CNPM = -g --registry HTTPS: //registry.npm.taobao.org

  If you find that your installation was successful, use cnpm but found not find the command, then that is a problem with your environment variables, path environment variable to the installation path you add a node on the line, such as "; C: \ Program Files \ nodejs \ node_modules "

5, the installation of scaffolding vue vue-cli
  command: CNPM the install -g vue-cli

  After a successful installation can  -V vue  View vue version
6, cd to initialize vue projects under the corresponding directory
  command: vue the init WebPACK My-Project
      Project name Project name 
      Project description Project Name Description 
      Author Author mailbox 
      Use ESLint to lint your code if? ESlist need grammar checker 
      Setup unit tests with Karma + Mocha? need unit testing 
      Setup e2e tests with Nightwatch? Yes e2e need to test 
7, package.json project resource-dependent, if you want to run this project requires cnpm install  install dependencies ( executed directly in the path of the project file folder)
8, use the command cnpm run dev to start the project, the browser will open  http: // localhost: 8080 / # /  see the following results

      

  Belongs to the development of hot deployment state, the browser will automatically refresh the code is stored, an error message is also very friendly.

 

9, compiler package  cnpm run build

  Will compile the package to the project dist folder, then we can deploy to the server (Note: If you directly open the index.html, may be a blank page, which is due js path you have problems cited)

     

10, plug-in installation axios 

  cnpm install axios // production environment
  npm install --save axios vue-axios // test environment 
  both download
  writes the following in main.js in:
  Vue from Import 'VUE' 
  Import from Axios 'Axios' 
  Import from VueAxios 'VUE-Axios' 
  Vue.use (VueAxios, Axios)
  the page usage:
  Vue.axios.get(api).then((response) => {
    console.log(response.data)
  })
  this.axios.get(api).then((response) => {
    console.log(response.data)
  }) 
  this.$http.get(api).then((response) => {
    console.log(response.data)
  })
  Or write the following in main.js in:

    axios from import 'axios'
    Vue.prototype. $ axios = axios

  Use page

  this.$axios.get(api).then((response) => {
    console.log(response.data)
  })

11、安装jquery依赖
  npm install jquery --save
  Writes the following in main.js in: 
    Import $ from 'jQuery' 
12, scaffolding catalog description

         

Guess you like

Origin www.cnblogs.com/yshang/p/11238513.html