Axios of Vue project based on VUE-CLI send request using 5--axios method

Source: Internet
Author: User

Since JQ has Ajax methods, then Axios has no Axios method. The answer is yes, still hiding the domain name

1. Configure Config/index.js: Troubleshoot cross-domain issues dev: {env:require ('./dev.env '), port:8008, Autoopenbrowser:false, Assetssubdirector Y: ' Static ', Assetspublicpath: '/', proxytable: {'/ajaxurl ': {target: ' https://www.aaaaaaa.com/', Changeo  Rigin:true, Pathrewrite: {' ^/ajaxurl ': '/'}}} 2.main.js: Configure Axios to prototype chain, note 25th line import Vue from
' Vue ' import App from '/app ' import Axios from ' Axios ' Vue.prototype. $http =axios; New Vue ({el: ' #app ', render:h => H (APP)}) 3.app.vue: Use request, get for example, line 45th to 60th behavior method, prefer this <template> <div id= "App" > huoqu <button @click = "Myajax" > Get home Information </button> </div> </template> <script> ex Port Default {name: ' app ', components: {}, Data:function () {}, methods: {myajax:function () {this. $http
				({method: ' Get ', url: '/ajaxurl/welfare/gpa/brand/list ', data: {page:1, size:10}
						}). Then (response => {console.log ("successful Request"); ConsOle.log (response);
						}, Response => {console.log ("request Failed");
					Console.log (response); })},}} </script> <style> </style>
The effect chart is as follows:

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.