Solve the axios cross-domain problem in two steps
first step
Find proxyTable in config/index.js (if not, add and change the configuration) and add the following content
proxyTable: {
/* 跨域 第一步 */
"/api":{
target:"http://localhost:9999",
changeOrigin:true,
pathRewrite:{
'^/api':''
}
}
},
Note: target is the address of the requested target server, others cannot be changed
Second step
Add content to the src/main.js file
Vue.prototype.HOST='/api';
Note: Add the /api of the host proxy, which is equivalent to directly visiting http://localhost:9999 when visiting the address
The entire configuration is as follows
Note: After the modification, you must restart, and you must restart
3. Request background data