鍍金池/ 問答/HTML/ vue中怎么可以做到一個(gè)列表中的數(shù)據(jù)tpye不同展示不同樣式?

vue中怎么可以做到一個(gè)列表中的數(shù)據(jù)tpye不同展示不同樣式?

我請求回來一段數(shù)據(jù),這段數(shù)據(jù)中的數(shù)據(jù)都有不同的type值,我怎么能做到展示不同的樣式還要展示完?

clipboard.png
效果如上 type=1時(shí)展示圖片并有一點(diǎn)遮罩層 type=0只展示標(biāo)題
<div v-for="item in hour">

<div class="hour-div" v-if='item.news_type==1'>
  <img class="hot img-responsive" @click=gonewinfo v-bind:src=item.cover alt="">
  <p class="dic">{{item.news_title}}</p>
</div>
<div class="hour-div-bom" v-if='item.news_type==0'>
  <router-link to="/newinfo" class="r-dic">{{item.news_title}}</router-link>
</div>

</div>
這樣寫對么

回答
編輯回答
孤毒
2017年5月5日 00:02
編輯回答
奧特蛋

使用 v-if 判斷,可以看一下例子就好了

2017年8月17日 10:25