码迷,mamicode.com
首页 > 移动开发 > 详细

axios获取本地文件配置步骤

时间:2019-11-12 01:07:31      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:eth   rom   请求   png   text   script   mount   import   get   

 

首先修改一下config文件夹下面的index.js文件里面的配置,如下:

技术图片

 

然后 ,通过axios 请求配置的接口

<script>
  import axios from ‘axios‘
  export default {
    name: ‘List‘,
    data(){
      return {
       list:[]
      }
    },
    mounted(){
     this.getData();//调用获取数据函数
    },
    methods:{
      //定义页面跳转函数
      goDetail(e){
        const id=e.currentTarget.getAttribute("id");
        const name=e.currentTarget.innerText;
        this.$router.push({
          path:‘detail‘,
          query:{id:id, name:name}
        })
      },
      //定义获取数据函数
      getData(){
         axios.get(‘/api/index.json‘).then((res)=>{
              if(res.status==200){
                this.list=res.data.data.list;
              }
         }).catch((error)=>{
             console.log(error);
         })
      }
    }
  }
</script>

  

axios获取本地文件配置步骤

标签:eth   rom   请求   png   text   script   mount   import   get   

原文地址:https://www.cnblogs.com/mengzhongfeixue/p/11839165.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!