頁面總體框架實現,實現小功能,循環出數據,總體代碼是上一篇html
修改部門代碼vue
app.vuenode
<yd-flexbox>webpack
<yd-flexbox-item>能耗排行</yd-flexbox-item>web
<yd-flexbox-item>房間號</yd-flexbox-item>微信
<yd-flexbox-item>能耗程度</yd-flexbox-item>app
</yd-flexbox>框架
<div id="data">ide
<yd-flexbox v-for="item in database":key="item.rank">flex
<yd-flexbox-item>{{item.rank}}</yd-flexbox-item>
<yd-flexbox-item>{{item.rid}}</yd-flexbox-item>
<yd-flexbox-item>{{item.energy}}</yd-flexbox-item>
</yd-flexbox>
</div>
/**
注意: v-for循環list時,要指明key,否則會報錯信息
官方文檔地址 https://cn.vuejs.org/v2/guide/list.html
*/
<script>
export default {
name: 'Powerrank',
data(){
return{
database:[
{
rank:1,
rid:123,
energy:6
},
{
rank:2,
rid:123,
energy:6
},
{
rank:3,
rid:123,
energy:6
}
],
value:''
}
}
}
</script>
效果圖