建立下拉框:this
<div id="chart-shopname" class="chart-shopname">
<select v-model="selected" @change="changeShop">
<option disabled value="">請選擇</option>
<option v-for="(store,index) in secondSummary.t0RealtimeStoreList" :value="store.shopName">{{store.shopName}}</option>
</select>
</div>
點擊相應選項,出現相應數據,試了用watch監聽,而後發現一種更簡單的方法spa
changeShop(){ this.secondSummary.t0RealtimeStoreList.forEach(item=>{ if(this.selected === item.shopName){ this.secondSummary20 = item.totalTop20Prod; } }) },
直接用if 判斷selected,而後調用code