Vue3 Project Init and Some Basic Config

Vue3 was released for a while. In this post, I will initiate a new Vue3 project with Vue Cli.

Tools Used

I will use Vue Cli 4.x and Node >= v8 to create the project. Also I will configure the following as well:

  • Vue-Router for routing
  • Vuex for centralized state management
  • Axios for requests

Install Vue Cli

npm install -g @vue/cli
Bash

Create a Vue project

  • To create a vue project, run
vue create my_vue_project
Bash
  • Select Mannually select features
  • Select features
  • Choose version 3.x
  • The rest of features I selected can view below

Run the project

To run the project, cd into the folder and npm run serve to start the vue project

Install Axios

Additionally, I’ll install axios to handle the requests.

npm install axios
Bash

Configure Axios

I’ll make some simple axios configurations. First create a utils folder under src folder

{% asset_img 'utils.PNG' %}

Then create a request.js file, in which I’ll set up request and response interceptor services as such:

import axios from "axios";

const service = axios.create({})

service.interceptors.request.use(
  config => {
    return config
  })


service.interceptors.response.use(
  response => {

  }
)

export default service
Javascript

   Reprint policy


《Vue3 Project Init and Some Basic Config》 by Isaac Zhou is licensed under a Creative Commons Attribution 4.0 International License