Z
Z
Zubastik_12017-10-17 13:57:34
Vue.js
Zubastik_1, 2017-10-17 13:57:34

How to show the loading icon in the body of the message being loaded in a loop, vue.js?

I output an array of messages

<ul  v-for="item in messages">
    ...
        {{ item.message }}
    ...
</ul>

Here is the array itself
{
  "status": "",
  "messages": [
    {
      "user": "Nikolay",
      "message": "hello"
    },
    {
      "user": "Petr",
      "message": "hi"
    }
  ]
}

Question. The data is received by Ajax with a delay of 2 seconds approximately. The loading icon works, but I would like it like this: "message": "loader" and after 2 seconds "message": "hi"
Tried to push data before and after the ajax request, but it turns out two separate messages. it and is clear - 2 iterations. How would this be combined? I would like to show the download icon in the message wrapper itself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-17
@Zubastik_1

I tried pushing data before and after the Ajax request, but I get two separate messages. it and is clear - 2 iterations.

And you do this: before the request, add a new object to messages, remember the index, after the request for the index, update the data. Something like this (instead of the setTimeout ajax, but I think the principle is clear).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question