zoukankan      html  css  js  c++  java
  • axios发送get请求示例

     1 <template>
     2   <div id="app">
     3     <!--<img src="./assets/logo.png">-->
     4     <router-view></router-view>
     5     <button @click="send">发送ajax请求</button>
     6   </div>
     7 
     8 </template>
     9 
    10 <script>
    11   import axios from 'axios'
    12   export default {
    13     name: 'app',
    14     data() {
    15       return {
    16         msg: 'Welcome to Your Vue.js App'
    17       }
    18     },
    19     methods:{
    20       send(){axios.get('https://api.github.com/users/Tiny3300')
    21         .then(resp =>{
    22           console.log(resp.data);
    23         }).catch(err =>{
    24           console.log(err);
    25         });}
    26     }
    27   }
    28 </script>
    29 
    30 <style>
    31   #app {
    32     font-family: 'Avenir', Helvetica, Arial, sans-serif;
    33     -webkit-font-smoothing: antialiased;
    34     -moz-osx-font-smoothing: grayscale;
    35     text-align: center;
    36     color: #2c3e50;
    37     margin-top: 60px;
    38   }
    39 </style>
    View Code

    <template>
    <div id="app">
    <!--<img src="./assets/logo.png">-->
    <router-view></router-view>
    <button @click="send">发送ajax请求</button>
    </div>

    </template>

    <script>
    import axios from 'axios'
    export default {
    name: 'app',
    data() {
    return {
    msg: 'Welcome to Your Vue.js App'
    }
    },
    methods:{
    send(){axios.get('https://api.github.com/users/Tiny3300')
    .then(resp =>{
    console.log(resp.data);
    }).catch(err =>{
    console.log(err);
    });}
    }
    }
    </script>

    <style>
    #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 60px;
    }
    </style>
  • 相关阅读:
    bzoj 2152: 聪聪可可
    bzoj 2143: 飞飞侠
    bzoj 2132: 圈地计划
    bzoj 2127: happiness
    bzoj 2124: 等差子序列
    bzoj 2120: 数颜色
    对MySQL数据类型的认识
    MySQL详解--锁,事务(转)
    mysql 5.7快速部署
    elasticsearch报错[WARN ][bootstrap ] Unable to lock JVM Memory: error=12,reason=Cannot allocate memory,解决
  • 原文地址:https://www.cnblogs.com/mx2036/p/7478772.html
Copyright © 2011-2022 走看看