Created
February 22, 2017 15:54
-
-
Save mdunbavan/a711568f8daf23d673fb84c83209284d to your computer and use it in GitHub Desktop.
veux orderby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const store = new Vuex.Store({ | |
state: { | |
products: [ | |
], | |
posts: [] | |
}, | |
mutations: { | |
addProducts (state, product) { | |
// mutate state | |
state.products.push(product) | |
}, | |
addPosts (state, post) { | |
// mutate state | |
state.products.push(post) | |
} | |
} | |
}) | |
store.dispatch('addProducts'); | |
store.dispatch('addPosts'); | |
const ListComp = { | |
template: ` | |
<div class="wrapper grid" id="start-parralex"> | |
<div class="grid__item large--one-third medium--one-whole no-padding" v-for="(key, index) in products"> | |
<div v-if="products[index].vendor"> | |
<router-link :to="'/products/'+ index" active-class="active" class="product grow"> | |
<div class="inner-container relative"> | |
<div class="pad-normal absolute top-0 left-0 z-2 large--one-whole product-color"> | |
<p class="lyon-text">{{products[index].title}}</p> | |
<p class="univers uppercase smaller body-size"> | |
Buy now | |
</p> | |
</div> | |
<div class="z-1 relative" v-for="image in products[index].images"> | |
<img class="scale-with-grid archives-image" v-bind:src="image.src" v-bind:alt="image.id"> | |
</div> | |
</div> | |
<transition | |
v-if="$route.params.id == index" | |
appear | |
name="slide-fade"> | |
<router-view :key="$route.params.id"></router-view> | |
</transition> | |
</router-link> | |
</div> | |
<div v-else> | |
blog | |
</div> | |
</div> | |
</div> | |
`, | |
data() { | |
return { | |
fade: true | |
}; | |
}, | |
getters: { | |
productsByDate: state => products.orderBy('id') | |
}, | |
computed: { | |
products() { | |
return this.$store.state.products; | |
//return this.$store.getters.productsByDate; | |
}, | |
posts() { | |
return this.$store.state.posts; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment