Skip to content

Commit

Permalink
add vuex yoooo
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuslerma committed Jul 13, 2017
1 parent 6cc6b28 commit 03fec43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<input type="checkbox"
@click="changeShowTable">
<component
:is='currentCategoryView'
:categories='categories'>
:is='currentCategoryView'>
</component>
</div>
</template>
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Vue from 'vue'
import App from './App.vue'
import store from './vuex/store'

new Vue({
el: '#app',
store,
render: h => h(App)
})
24 changes: 9 additions & 15 deletions src/mixins/CategoriesMixin.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
const axios = require('axios')
const mapGetters = require('vuex').mapGetters
const mapActions = require('vuex').mapActions

module.exports = {
module.exports = {
listMixin: {
data() {
return {
categories: []
}
computed: {
...mapGetters({
'categories': 'getAllCategories'
})
},
methods: {
selectCategory (category) {
category.selected = !category.selected
this.$emit('selectcategory', category)
}
...mapActions(['fetchCategories', 'selectCategory'])
},
mounted: function () {
var url = 'https://raw.githubusercontent.com/jesuslerma/vuejs101-guide/master/categories.json'
var that = this

axios.get(url).then(function (response) {
that.categories = response.data
})
this.fetchCategories()
}
}
}

0 comments on commit 03fec43

Please sign in to comment.