this is the addition of index.js to proxyTable in config
proxyTable: {
"/research": {
target: "https://api.shenjian.io/?appid=c36a22e564a2954e&keyword=a&pageNo=1&pageSize=20",
//
changeOrigin: true, //
pathRewrite: {
"^/research": "/c" //
}
}
}
add index.js interface in api
export default {
songsearch: "/research"
}
call the ajax function in
store
mutations: {
changeKeyword(state, x) {
ajax(require.songsearch)
}
}
ajax
const ajax = function (url) {
return new Promise(function (resolve, reject) {
axios.get(url).then(res => {
resolve(res);
}).catch(reject);
});
}
this is the result
I just started to learn that vue, wants to be a web player and has already got the api, but the axios request needs to be cross-domain, so it uses the proxyTable method to proxy, but the request address becomes the port number, why?