(Xviii) path problem

We'll meet a lot of places need to enter the address of the background at the time of writing small front-end code for the program, these places would be more difficult to maintain in the future, so we have to put it all together

1. In the outermost create a config / api.js file

基础的url
const rootUrl = 'http://127.0.0.1:8000/api'; module.exports = { MsgCode: rootUrl + "/msg/", Login: rootUrl + "/login/", Credential: rootUrl + "/oss/credential/", News: rootUrl + "/news/", NewsDetail: rootUrl + "/news/", // 后面加ID Comment:rootUrl + '/comment/', }

2. Use the corresponding place

 

Guess you like

Origin www.cnblogs.com/a438842265/p/12461357.html