vue_ajax 请求
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));
}
--------小尾巴
________一个人欣赏-最后一朵颜色的消逝-忠诚于我的是·一颗叫做野的心.决不受人奴役.怒火中生的那一刻·终将结束...