Vue-resource usage
Import vue from ' Vue' Vue-resource 'vue.use (vueresource)
Do you think it's all right? Below directly get/post/jsonp all sorts of liking? And then the egg!
Write a simple GET request, and then compile with Webpack when there is a wood to find the following error:
Modules not found, can ' t resolve './package ' What the hell
It means that this module cannot be found, why can't I find it? I also did not take the initiative to install this module, what is wrong with the other package? Or should I take the initiative to install the package module?
The most stupid way to remove node_modules, re-install the NPM test will not be wrong, OK, npm install suddenly found the following ghost
Look at the yellow hint of the piece of crap. Package require OS (Darwin) isn't compatible with your platform (Win32)
What the hell is Darwin?
Explanation of Baidu Encyclopedia:
Darwin was an open source operating system released by Apple Computer in 2000. Darwin is the operating system component of the MACOSX operating environment.
This is a stark discrimination against Windows! There is no money for Mac to do, there is no other way to solve the package
I did not find, no way, vue-resource can not go to compile, direct introduction?
Fortunately, this morning at Vue's tutorial video, the author mentions artifact Axios.
After the original Vue was updated to 2.0, the author declared that the Vue-resource was no longer updated, but recommended Axios. Heart Exultation Wow, finally have hope, is not changed Axios on it can
Quickly try to remove the Vue-resource.min.js source code in the folder, and then uninstall the corresponding NPM package, and then try to Axios
NPM install Axios--save-Dev
' Vue' ' Axios '
Then direct Axios.get (), Webpack compile, unexpectedly no error, perfect run!
Run an example and find the request is OK! Cheers inside! It's so perfect!
Then look at the Axios Github:https://github.com/mzabriskie/axios 16,518 star, and Vue-resource only 4,800, tears ran long ago should choose Axios
Whether you encounter a hole or not, hurry up and use Axios.
As to what are the advantages of Axios back, or which pits, wait a while, and at least now you can run.
Abandon Vue-resource embrace Axios