Php 我在vue.js中使用v-for显示数据库项时遇到问题
我在用v-for显示数据库项时遇到问题。 我从数据库中获取数据并在控制台日志中显示,但在app.vue中不显示 app.vuePhp 我在vue.js中使用v-for显示数据库项时遇到问题,php,html,vue.js,Php,Html,Vue.js,我在用v-for显示数据库项时遇到问题。 我从数据库中获取数据并在控制台日志中显示,但在app.vue中不显示 app.vue <template> <div class="container"> <div class="row well"> <div id='app'><input type='button' @click='allRecords
<template>
<div class="container">
<div class="row well">
<div id='app'><input type='button' @click='allRecords()' value='Select All newss'>
<div class="col-sm-3 alert-success p" v-for="news in newss" :key="news">
<p>{{ news.news_num }}</p>
<p>{{ news.news_title }}</p>
<p>{{ news.news_description }}</p>
<p>{{ news.news_year }}/{{ news.news_month }}/{{ news.news_day }}</p>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
newss: [],
newsid: 0,
};
},
methods: {
allRecords: function() {
axios.get('/api.php')
.then(function(response) {
app.newss = response.data;
console.log(app.newss);
})
.catch(function(error) {
console.log(error);
});
}
}
}
</script>
{{news.news_num}
{{news.news_title}
{{news.news_description}
{{news.news\u year}/{{news.news\u month}/{{news.news\u day}
导出默认值{
数据(){
返回{
新闻:[],
新闻ID:0,
};
},
方法:{
allRecords:function(){
get('/api.php')
.然后(功能(响应){
app.news=response.data;
console.log(app.news);
})
.catch(函数(错误){
console.log(错误);
});
}
}
}
您能否将console.log(app.news)的输出包括在内
?可能不是问题,但是v-for=“news in news”:key=“news”
应该是v-for=“(news,i)in news”:key=“i”
1.0:{news\u id:“2”,news\u num:“2”,news\u title:“H”,news\u description:“2h”,news\u imgurl:“2.jpg”…}2.1:{news\u id:“14”,news\u num:“15”,news\u title:“B”,news\u description:“3b”,news\u:“15.jpg”,…}3.length:24.proto:Array(0)你能发布console.log(JSON.stringify(app.news));
?等等,app
到底是什么?你能试试this.newss=response.data;
?