axios动态数据的获取

跨域:前端处理、后端处理
前端方法:代理
后端加header 
 
第一步:全局安装axios
cnpm install axios --save-dev     
 
第二步:
methods:{
    getData:function(){
          axios.get("url").then(res=>{
              console.log(res);
              this.item = res;
             }
         ),(error) =>{
          console.log(error)
         }
     }
}
 
mounted:function(){
    this.getData();
}
posted @ 2019-10-16 14:22  马教主  阅读(525)  评论(0编辑  收藏  举报