Abandon Vue-resource embrace Axios

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.