1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/client/app/components/Content/Trending.vue
2016-10-14 12:15:54 +02:00

60 lines
1.1 KiB
Vue

<template>
<main>
<div class="wrap-content" v-if=" ! loading">
<Item v-for="(item, index) in trendingItems" :item="item" :key="index"></Item>
</div>
<span class="loader fullsize-loader" v-if="loading"><i></i></span>
</main>
</template>
<script>
import Item from './Item.vue';
import Helper from '../../helper';
import { mapState, mapMutations } from 'vuex'
export default {
mixins: [Helper],
created() {
this.initTrending();
},
data() {
return {
trendingItems: []
}
},
computed: {
...mapState({
loading: state => state.loading
})
},
methods: {
...mapMutations([ 'SET_LOADING' ]),
initTrending() {
this.SET_LOADING(true);
this.$http.get(`${config.api}/trending`).then(value => {
this.trendingItems = value.body;
this.SET_LOADING(false);
})
}
},
components: {
Item
},
watch: {
$route() {
this.scrollToTop();
this.initTrending();
}
}
}
</script>