import Mock from 'mockjs';
export default Mock.mock('http://g.cn','post',{
'name': '@name',
'age|1-100': 100,
'color': '@color'
});
複製代碼
import axios from 'axios'
Vue.prototype.$http = axios;
複製代碼
這樣一引用你就能夠全局使用this.axios方法來調用接口。vue
axiosTest(){
this.$http.post('http://g.cn').then(
(successData) => {console.log(successData.data);},
(fileData) => {console.log(fileData);})
},
複製代碼
{name: "Jennifer Young", age: 69, color: "#d0f279"}
複製代碼