Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Does axios belong to vue?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you whether axios is inside the vue, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Axios is not from vue. Axios is a Promise-based tool library for sending http requests. It is not a third-party plug-in in vue. When you use it, you cannot install the plug-in through "Vue.use ()". You need to bind it on the prototype.

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

Axios is not from vue.

Axios is a library, not a third-party plug-in in vue. You cannot install the plug-in through Vue.use () when using it, and you need to bind it on the prototype.

Axios is a promise-based http library that can be run in browsers and node.js. Then the author you Yuxi decisively abandoned the maintenance of its official library vue-resource and directly recommended the axios library.

The role of axios: axios is mainly used to initiate requests to the background, and to do more in the request is a controllable function.

Characteristics

Support for Promise API

Intercept requests and responses. Intercept request, you can filter request parameters; intercept response, you can handle response exception

Cancel the request. The request can be cancelled manually

Using axios in vue

1. Install the axios module

$cnpm install-- save axios # installation

2. Reference axios in mian.js and state it to the prototype chain. When using a plug-in, it is generally introduced in the entry file main.js, because mian.js is the first file that the project runs:

Import Vue from 'vue'import axios from' axios'Vue.prototype.$http = axios

Usage:

3. Vue-axios is a small wrapper that integrates axios into Vue.js and can be installed like a plug-in.

$cnpm install-- save axios vue-axios # installation

Referencing axios,vue-axios in mian.js and using the plug-in through the global method Vue.use () is equivalent to calling the install method:

Import Vue from 'vue'import axios from' axios'import VueAxios from 'vue-axios'Vue.use (VueAxios, axios)

Usage:

$cnpm install-save axios vue-axios

After installing axios,vue-axios, you can see the source code for vue-axios in the node_modules/_vue-axios/src/index.js under the Vue project. Using the plug-in method of Vue, it is more in line with the overall ecological environment of Vue. It feels a little rough to write a prototype chain directly, which is not recommended unless it is a very low-level implementation.

The above is all the content of this article "is axios in vue?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report