xinggevip

Vue2.x Cli3.xHttp
安装vue-resource依赖npm install vue-resource --save-dev main....
扫描右侧二维码阅读全文
25
2019/05

Vue2.x Cli3.xHttp

安装vue-resource依赖

npm install vue-resource --save-dev

main.js

import VueResource from 'vue-resource' 
Vue.use(VueResource)

About.vue

<template>
  <div class="about">
    <h1>This is an about page</h1>
    <div>
      <ul>
        <li v-for="num in users">
            {{num.name}}
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
export default {
  name: 'about',
  created(){
    this.$http.get("http://jsonplaceholder.typicode.com/users")
      .then((data) => {
        console.log(data);
        this.users = data.body;
      })
  },
  data(){
    return{
      users:[],
    }
  }
}
</script>
Last modification:May 26th, 2019 at 02:28 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment