A little problem, a little problem.

has the following comment data, two times subtract in the format can get "X days later append comment"
but how to get X, the calculation property seems to be possible, but can not be written.

        list:[
          {
            ...
            time:1111,  //
            againTime:2222 //,
          },
          {
            ...
            time:1111,
            againTime:
          },
          {
            ...
            time:1111,
            againTime:3333
          },
        ]
Apr.24,2022

The

comment list is output using v-for, so it is assumed that each object is item
write the function in methods:

tdoa(time,againTime){
    let usedTime = againTime - time
    let days = Math.floor(usedTime/(24*3600*1000));
    return days
}

use tdoa (item.time,item.againTime) when using

principle: all the times in the list should be timestamps. The difference between the two timestamps is the number of milliseconds, and then converted into days.

when rendering, you need to consider the situation where no comments are appended, so remember to add a VMI if = "item.againTime"


if you can guarantee that both data are available, write them directly into the htmlui template and don't struggle with the data. If you think the business may change, take list.item as a parameter and write a method to reference


computed:{
    days(){
      return this.list.filter((t) => {
          return t.againTime - t.time;
      })
    }
}
in the template.
Menu