Use Vue scaffolding (vue-cli) to build a vue project from scratch

Note: Before building the project, please install some global tools (such as: node, vue-cli, etc.)

  • Node installation: Go to the official website of node (https://nodejs.org/en/) to download and install node. After installing node, you can use npm commands normally
  • Install the vue-cli tool globally: npm install vue-cli -g

Start creating the project:

  • Find a suitable location, open a command window, and use vue to initialize a new webpack-based project

  

vue init webpack vue-demo //Note that if the name is too long, it will have an error message, just like VueDemo, we can write it as vue-demo

 As shown in the figure above, it will show various prompts, and there are things that need to be installed. You can install things according to your own needs.

 After generation, it will generate a ready-made vue project shelf in the location you just selected, like this:

Startup project:

 

npm run dev

Open the project in the browser menu bar according to the above address>

 The project has been started successfully, and we can continue with the tools we need in our project, such as:

npm install vue-router -- save (router management module)
npm install vuex -- save (state management module)
npm install vue -resource --save (network request module)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324841995&siteId=291194637