Use of the Axios explained in Vue instance

Source: Internet
Author: User

This article to explain the use of Axios plug-ins, Axios is used to do data interaction plug-ins.

This article will be based on the Vue example to explain the use of the project's source code to expand the Vue-router.

Axios Steps to use:

1. Installing Axios npm Install Axios--save-dev

2. Introduction of Axios Import Axios from ' Axios ' on the page

3. For ease of use we hang the Axios to Vue.prototype. $http this prototype.

Vue.prototype. $http = Axios

4. Call the Axios method directly in the page

After the basic steps are clear, start the project below:

Create a data file in the static directory of the project to create a Article.dada file to hold the simulated data.

The structure is as follows:

Then in the Portal file Main.js import Axios

The code is as follows:

Then using Axios in the News.vue component, here is the core code.

When finished, the page works as follows:

Project Code Address:

Use of the Axios explained in Vue instance

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.