Node.js 如何使用VueJs和Axios显示表中的所有用户?
我正试图在vueJs中将我的用户从数据库(MYSQL)显示到一个表中。 在下面的代码中,我试图在表中显示用户,但它什么也不显示。另外,当我转到控制台.log时,我可以看到Node.js 如何使用VueJs和Axios显示表中的所有用户?,node.js,api,vue.js,Node.js,Api,Vue.js,我正试图在vueJs中将我的用户从数据库(MYSQL)显示到一个表中。 在下面的代码中,我试图在表中显示用户,但它什么也不显示。另外,当我转到控制台.log时,我可以看到 数组(4)0:{…}1:{…}2:{…}3:{…} 每次单击0:{…},我都会看到我的JSON。我应该如何在表中显示此代码 <template> <div class="container"> <div class="row"> <div class="col-md-8 col
- 数组(4)0:{…}1:{…}2:{…}3:{…}
<template>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">List of users</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>user.url</td>
<td>user.lastaname</td>
<td>user.email</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
用户名单
名字
姓氏
电子邮件
user.url
user.lastaname
user.email
还有剧本
<script>
import QrcodeVue from "qrcode.vue";
import axios from "axios";
export default {
data() {
return {
users: [],
};
},
methods: {
getUsers() {
axios
.get("localhost:2000/user/")
.then(response => (this.users = response.data))
.catch(error => console.log(error.message));
},
components: {
QrcodeVue
},
mounted() {
axios
.get("localhost:2000/user/")
.then(response => {
this.results = response.data[1];
console.log(this.results);
})
.catch(err => {
throw err;
});
}
};
</script>
从“qrcode.vue”导入QrcodeVue;
从“axios”导入axios;
导出默认值{
数据(){
返回{
用户:[],
};
},
方法:{
getUsers(){
axios
.get(“localhost:2000/user/”)
.then(response=>(this.users=response.data))
.catch(error=>console.log(error.message));
},
组成部分:{
QrcodeVue
},
安装的(){
axios
.get(“localhost:2000/user/”)
。然后(响应=>{
this.results=response.data[1];
console.log(this.results);
})
.catch(错误=>{
犯错误;
});
}
};
谢谢你的帮助
附言
在StackOverflow中,我也被问到了这一点
编辑:这是输出您忘记了花括号 下面是它的代码:
用户名单
名字
姓氏
电子邮件
{{user.url}}
{{user.lastname}
{{user.email}
Hi,你说失败了,这些代码当前显示的是错误还是什么?Hi@Toothgip它什么也不显示。谢谢!我已经调试了很长时间了。谢谢!