Vue.js 使用Vue和Axios呈现列表时,如何解决此问题?

Vue.js 使用Vue和Axios呈现列表时,如何解决此问题?,vue.js,axios,Vue.js,Axios,我在后端使用一个节点,在那里执行查询并通过JSON发送数据。该数据由axios在前端请求,并由Vue渲染。数据通常到达前端,问题是在呈现列表时,vue不会呈现 下面我将在后端发送查询代码: routeruser.post('/tesvue', function(req, res){ const teste =dadoslances.findAll() .then( function(resp){ res.json(resp) return resp

我在后端使用一个节点,在那里执行查询并通过JSON发送数据。该数据由axios在前端请求,并由Vue渲染。数据通常到达前端,问题是在呈现列表时,vue不会呈现

下面我将在后端发送查询代码:

routeruser.post('/tesvue', function(req, res){
   
  const teste =dadoslances.findAll()
  .then( function(resp){
    
    res.json(resp)
    return resp
  }, function(err){
    res.json({resp: "falha"})

    return err
  });

})
请求此查询数据的Vue代码如下:

var applance = new Vue({
el: '#lancapp',
data(){
        return {
        lances: []
         }
        
},
mounted(){          
             axios
                .post('/tesvue')
                .then(response =>( this.lances=response.data))
 
      
},

updated: function () {
  setInterval(   
        axios
        .post('/tesvue')
        .then(response =>( 
                console.log(response),
                this.lances=response.data))
        
        ,5000)
} 

})
如果我在模板中输入以下代码:

<div id="lancapp" >
   
   <p>{{ lances }}</p>

  </div>
每个用户放置一个想要获得对象的出价,这些出价必须以列表的形式用Vue动态呈现,但我无法做到这一点。有人能帮我发现这个问题吗

以下是我已经做过的一些尝试:

tentiva 1:

<div id="lancapp" v-for="item of lances" >
   
   <p>{{item.lance}}</p>
   <p>{{item.vontade}}</p>

  </div>

{{item.lance}

{{item.vontade}

tentiva 2:

<div id="lancapp" v-for="item of lances" :key="item.id">
   
   <p>{{item.lance}}</p>
   <p>{{item.vontade}}</p>

  </div>

{{item.lance}

{{item.vontade}

Tentiva 3:

<div id="lancapp" v-for="item of lances['data']" >
   
   <p>{{item.lance}}</p>
   <p>{{item.vontade}}</p>

  </div>

{{item.lance}

{{item.vontade}

tentiva 4:

 <div id="lancapp" v-for="{item, id} of lances" :key="item.id">
   
   <p>{{item.lance}}</p>
   <p>{{item.vontade}}</p>

  </div>

{{item.lance}

{{item.vontade}


由于数据以简单变量的形式呈现,我只尝试了模板。如果有人能提供帮助,我将提前向您表示感谢。

您必须在另一个div中进行渲染。您正在尝试在Vue实例的装入点上进行渲染

newvue({
el:“应用程序”,
数据:{
项目:[]
},
安装的(){
取('https://rickandmortyapi.com/api/character/?page=1')
.then(res=>res.json())
。然后(res=>{
this.items=res.results
})
.catch(err=>console.error(err))
}
});

-{{item.id}:{{item.name}}{{item.status}}{124;{item.species}


您能编辑您的问题标题并将其翻译成英语吗?
 <div id="lancapp" v-for="{item, id} of lances" :key="item.id">
   
   <p>{{item.lance}}</p>
   <p>{{item.vontade}}</p>

  </div>