vue-axios

                                           vue-axios

1、安装方法
npm install axios

2、在main.js中引入axios;

import axios from 'axios'
Vue.prototype.$axios = axios

3、使用:

this.$axios('http://localhost/20180801_vue_tpl/XFXadmin/public/index.php/admin/user/register_new', {
			 params: {
					 firstName: this.register_tel
					  }
		})
		.then(function (response) {
		    console.log(response);
		})
		.catch(function (error) {
		     console.log(error);
	    });

4、解决权限问题后台:


header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE');

猜你喜欢

转载自blog.csdn.net/awake720/article/details/81607602