属性或方法“ info”未在实例上定义,但在渲染期间被引用

时间:2019-09-11 14:53:10

标签: rest vue.js axios

我正在尝试使用Vue.js显示来自其余API的信息 在一个组件中,我想显示用户...

<template>
    <div>
        <h1>User Manager</h1>
        <p>
            {{ users }}
        </p>
    </div>
</template>

在脚本部分:

<script>
import {AxiosInstance as axios} from "axios";

export default {
  name: "User",
  data(){
    return{
      users: null
    }
  },
  methods: {
    getUsers(){
      axios.get("http://localhost:4000/api/users").then(response => {
        console.log(response);
        this.users = response.data;
      });
    }
  },
  mounted(){
    this.getUsers();
  }
}
</script>
<style scoped></style>

很不幸,我收到一条错误消息,例如: 挂接钩中的错误:“ TypeError:无法读取未定义的属性'get'” TypeError:无法读取未定义的属性“ get” ...

0 个答案:

没有答案