1. 程式人生 > >向後臺發送數據vue

向後臺發送數據vue

response hat 數據 引入 orm resp post function app

在main.js中添加

import axios from ‘axios‘;
Vue.prototype.$http = axios;

在需要的登錄vue組件中引入:

需要先安裝qs cnpm install qs -d

import qs from ‘qs‘

最後

this.$http.post(‘http://tapi.funxdata.com/login/login‘, qs.stringify({
             ‘type‘:‘wechat‘,
             ‘code‘:res.code
            }),{
              headers: {
              
‘Content-Type‘: ‘application/x-www-form-urlencoded;charset=UTF-8‘ } }).then(function (response) { console.log(response); }).catch(function (error) { console.log(error); });

向後臺發送數據vue