There are roughly three problems with Vue interacting with Axios:
1: Debugging cross-domain issues locally?
2:post request, the argument failed, causing the request to fail?
3:axios reference, referenced in the component used
Solution:
Question one: cross-domain?
Troubleshoot local debugging cross-domain issues?
Reverse proxy----This needs to be in the configuration file to change the configuration, there is a config below the index.js file
is not modified, as to the specific how to modify, you can Baidu, of course, if it is not the words on the debugging, first write the code well, NPM run build package to the background in his debugging
Issue two: The POST request, the argument is unsuccessful, causing the request to fail? (A GET request can be done directly according to the document)
Why?
Reason: Because the Axios POST request when the reference time and the traditional Ajax a little different, not the way from the submission, said the simple point in
If the interface you are requesting is this:http://localhost:8086/web/checkSkill/getSkillList? Key=123¤tpageno=1 , you'll have to deal with it.
How to deal with: Qs.stringify ();
Of course, you need to refer to the QS before use:
As for the need to first NPM install QS--save this with you, as if you can,
There is also a possible background to receive the parameter format is JSON object Format , what to do? See:
Just deal with that.
Question three: Axios reference
Is that you use the interaction in that component and you need to refer to it in this component first,
Is the import Axios from ' Axios ' I was in the overall (main.js) in the quote, and then began to use in other components, found not to work, only to quote,
Of course, before using axios do not forget, first install Axios NPM installed Axios--save Specific can read the document!!!!
Vue2.0 use Axios to interact inside the pit