[uni-app] [02] Request the global configuration of the domain name.

Regarding the request of uni-app, you can visit the official document https://uniapp.dcloud.net.cn/api/request/request.html

One point worth noting is the issue of global domain name configuration.

Because the local test is localhost, but the actual deployment is separated from the front and back ends, the domain name is not localhost, and the port number may also need to be changed. If you don’t use a global variable to replace the domain name, then you can’t change them one by one in the later stage...

So how to set global variables. It is written or
written online . I've written it like this before, and it hasn't taken effect. Let's first look at a structure of the content of the main.js file.Vue.prototype……App.prototype……

image

First, it is written createApp()in

Then, one should writeapp..config.globalProperties.$……=……

Pay attention to where this appears.
Then when you use it you can:

image

Don't use this call directly in axios!

Guess you like

Origin blog.csdn.net/ks2686/article/details/130334187