vue-resource  是vue的ajax请求插件

vue-resource文档:https://github.com/vuejs/vue-resource/blob/master/docs/http.md

vue-resouce 已经解决了vue跨域问题

栗子:

 

this.$http.post(“http://192.168.1.25:20070/api/TypeItems/VehicleBrand”,{pagenum:0,pagesize:15,VehicleType:1}).then((response) => {

response = response.body;
    console.log(response.data);//需要这样获取到数组
});

 

url集中整理获取

新建一个配置文件 config.js 而后在文件中整理url

var ipUrl = 'http://192.168.1.25:20070';
var API = {
VehicleBrand: ipUrl+"/api/TypeItems/VehicleBrand"
}

module .exports = API; //创建模块api

而后在需要的页面引入config.js
import API from  'common/config'

就可以这样获取获取url使用了
this.$http.post(API.VehicleBrand,{pagenum:0,pagesize:15,VehicleType:1}).then((response) => {
response = response.body;
console.log(response.data);//需要这样获取到数组
});

学习笔记,如有不足请多多指教!