When VUEJS receives the value from the server, it assigns a value to the array.

the data received on the server is [{"name": "TOM", "age": "16"}, {"name": "JACK", "age": "18"}, {"name": "marry", "age": "20"}]
I think there is something wrong with the loop code in html.

<ul v-for="item in items">
<li>{{ item.name }}</li>
<li>{{ item.age }}</li>
</ul>
export default {
    data () {
      return {
        header:"",
        items: [
          {
            name:"",
            age:""
          }
        ]
      }
    },
    methods:{
      postdata(){
        var user_id = this.getcookies("user_id");
        this.$http.post("http://example.com/user",{
            userID:user_id
        }).then(function(data){
            this.items=data.body.data
        }
        )
      }
    }
  }
Feb.26,2021

< li VFF = "v in items" >

{{v.name}}

{{v.age}}


there is no problem with the loop. This.items got it wrong. It belongs to the this pointing problem, and you didn't succeed in assigning the value.

this.$http.post('http://example.com/user',{
            userID:user_id
        }).then((data)=>{//
            this.items=data.body.data//thisVue
        }
        )

should be the this pointing problem, var self = this;


this scope problem. Then ((res) = > {}) write

Menu