yarn add vue-resource axios
npm install --save axios pubsub-js
// import VueResource from "vue-resource"
// Vue.use(VueResource);
import axios from "axios";
mounted: {
const url="https://api.github.com/search/users?q=aa"
const url="https://api.github.com/search/repositories?q=v&sort=stars"
// this.$http.get(url).then(response=>{ // vue-resourve
axios.get(url).then(response=>{get(url).then(response=>{ // axios
const result = response.data;
const {name, html_url} = result.items[0];
this.repoName = name;
this.repoUrl = html_url;
}).catch(err=>console.log("请求失败:"+err));
}