zoukankan      html  css  js  c++  java
  • vue-axios请求

    <template>
     <div>
       <div v-if="!repoUrl">loding</div>
       <div v-else>most star repo is<a :href="repoUrl">{{repoName}}</a></div>
     </div>
    </template>
     
    <script>
    import axios from 'axios'
    export default{
        data(){
            return{
                repoUrl:'',
                repoName:''
            }
        },
        mounted(){
            const url='https://api.github.com/search/repositories?q=v&sort=stars'
              axios.get(url).then(response=>{
              
              const result=response.data
              const mostRepo=result.items[0]
    
              this.repoUrl=mostRepo.html_url
              this.repoName=mostRepo.name
            }).catch(error=>{
             alert('请求失败')
         })
           
        }
    }
    </script>
    
     <style>
     
    </style>
  • 相关阅读:
    vue组件的通信
    vue基础
    vue项目总结
    路由(4)传参
    路由(3)
    第一次作业
    JAVA-2.0-homework
    JAVA-2.0-上机
    JAVA-1.9-homework
    JAVA-1.9-上机
  • 原文地址:https://www.cnblogs.com/hack-ing/p/12093002.html
Copyright © 2011-2022 走看看