Insert a picture into the vue loop data

clipboard.png
whether the product data isNew is a new product, I want to add a picture as a separation between the new model and the old model. The data is in a list, and the background first gives the isNew is 1
how can I insert a picture in a for cycle

  "findGoodsList":[
            {
               
                "isNew":1,
                "sellingPoints":"Nike  AS W NSW CREW ARCHIVE 2017        857089-133",
                "goodsPrice":399,
                "sharePrice":319.2,
                "rebatePrice":39.9,
                "goodsId":"0d2420561a1b4360ad5f6a73067f0510",
                "stockNum":1,
                "labelName":"NEW BALANCE",
                "activeType":1,
                "sizeName":"A"
            },
         }

my current implementation is to write two for and then judge it by v-if = "isNew==1", but I feel that this is not friendly. I would appreciate it if you give me an idea.

 <ul class="product-list">
          
            <li class="product-item" @click="$router.push({path: "/product", query:{id: item.productId}})" v-for="(item,index) in proData" **v-if="item.isNew==1"**
              :key="index">
              <div class="item-posre">
                <img v-lazy="item.activityImg" alt="">
              </div>
              <div class="item-product-text">{{item.isNew}}{{item.sellingPoints}}</div>
              <p class="original-price">:<i>{{item.goodsPrice|formatMoney}}</i>

<p class="item-product-info"> <span><i></i>{{item.sharePrice|formatMoney}}</span> <button type="button" class="jx-btn" v-if="item.stockNum>0"></button> <button type="button" class="jx-btn none" v-else> </button>

<!--<div class="size">:{{item.sizeName}}</div>--> <!--<div class="size">:{{item.sizeName}}</div>--> </li> **<div v-if="bannerShow"><img style="width:100%" v-lazy="activity.bannerImg2" alt=""></div>** <li class="product-item" @click="$router.push({path: "/product", query:{id: item.productId}})" v-for="(item,index) in proData" **v-if="item.isNew==0"** :key="index"> <div class="item-posre"> <img v-lazy="item.activityImg" alt=""> </div> <div class="item-product-text"> {{item.isNew}}{{item.sellingPoints}}</div> <p class="original-price">:<i>{{item.goodsPrice|formatMoney}}</i>

<p class="item-product-info"> <span><i></i>{{item.sharePrice|formatMoney}}</span> <button type="button" class="jx-btn" v-if="item.stockNum>0"></button> <button type="button" class="jx-btn none" v-else> </button>

</li> </ul>
Jun.08,2021

well, the data is directly divided into two list. Then there is one at the top and one at the bottom.


var arr = [
    {new:1,b:2},
    {new:1,c:2},
    {new:2,b:1}
];
//new:1 2new ==2

var j = 0;
arr.forEach(function(item,i,arr1){
    if(arr1[i].new == 2){
        j = i;
    }
})

then splice adds an entry to ARR [j-1], which is before the first old one.


break down the computed, data


the final solution is to concat the data to proData

by circulating a paged request and inserting it into an object after requesting the data.
      list.forEach((item, index) => {
            // index>0 index-1
            if (item.isNew === 0 && index > 0 && list[index - 1].isNew === 1) {
              list.splice(index, 0, {
                'banner': true
              })
            }
          })

then when the data is displayed, it is judged that if item.banner, is ture, the picture data will be displayed. Combined with the ideas given by the two people upstairs, thank you very much

.
 <ul class="product-list">
           
            <li :class="{'product-item':!item.banner}" v-for="(item,index) in proData" :key="index">
              <div v-if="item.banner" style="margin-right:-10px"><img style="width:100%;" v-lazy="activity.bannerImg2" alt=""></div>
              <div v-else @click="$router.push({path: '/product', query:{id: item.productId}})">
                <div class="item-posre">
                  <img v-lazy="item.activityImg" alt="">
                </div>
                <div class="item-product-text">{{item.sellingPoints}}</div>
                <p class="original-price">:<i>{{item.goodsPrice|formatMoney}}</i>

<p class="item-product-info"> <span><i></i>{{item.sharePrice|formatMoney}}</span> <button type="button" class="jx-btn" v-if="item.stockNum>0"></button> <button type="button" class="jx-btn none" v-else> </button>

</div> <!--<div class="size">:{{item.sizeName}}</div>--> <!--<div class="size">:{{item.sizeName}}</div>--> </li> </ul>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45b7c-442e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45b7c-442e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?