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/cliBash
Create a Vue project
- To create a vue project, run
vue create my_vue_projectBash
- 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 axiosBash
Configure Axios
I’ll make some simple axios configurations. First create a utils folder under src folder
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 serviceJavascript