VUE realizes cross-domain in development environment

1. Cross-domain settings

Modify the content in the dev: proxyTable in the index.js file in the config folder of the VUE project (the default is no content):

Added content:

'/list': {
            target: 'http://xxxxxxxxxxx',
            changeOrigin:true,
            pathRewrite: {
                '^/list': '/'
            }
        }

 

 

2. Request method

In axios way:

The prefix list is what is set in 1.

3. It is only possible to achieve cross-domain in the development environment. The online project cannot achieve cross-domain according to this configuration.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325294390&siteId=291194637