Vue3.0 request local JSON file

Time:2021-1-12

Personal blog address

Axios request encapsulation

utils/api.js

import {get, post} from './http'


//Login
export const login = p => get('/json/login.json', p);
//Menu
export const menus = p => get('/json/menus.json', p);

Create a new JSON in public/ logo.json

{
  "status": "success",
  "code": 201,
  "data": {
    "token": ""
  }
}

This work adoptsCC agreementReprint must indicate the author and the link of this article

Seven statements