Skip to content

Commit

Permalink
pimp my app
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuslerma committed Jul 13, 2017
1 parent 06f1485 commit 9a2a7f8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
18 changes: 1 addition & 17 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@click="changeShowTable">
<component
:is='currentCategoryView'
@selectcategory='onSelectCategory'
:categories='categories'>
</component>
</div>
Expand All @@ -14,15 +13,12 @@
<script>
import CategoriesUl from './components/CategoriesUl.vue'
import CategoriesTable from './components/CategoriesTable.vue'
import axios from 'axios'
export default {
name: 'app',
data () {
return {
showTable: false,
categories: []
showTable: false
}
},
computed: {
Expand All @@ -33,21 +29,9 @@ export default {
methods: {
changeShowTable() {
this.showTable = !this.showTable
},
onSelectCategory (category) {
category.selected = !category.selected
}
},
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
})
},
components: {
categoriesUl: CategoriesUl,
categoriesTable: CategoriesTable
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoriesUl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</template>
<script >
import CategoryLi from './CategoryLi.vue'
import { listMixin } from '../mixins/CategoriesMixin'
import { listMixin } from '../mixins/CategoriesMixin'
export default {
mixins: [listMixin],
Expand Down
19 changes: 17 additions & 2 deletions src/mixins/CategoriesMixin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
const axios = require('axios')

module.exports = {
listMixin: {
props: ['categories'],
data() {
return {
categories: []
}
},
methods: {
selectCategory: function (category) {
selectCategory (category) {
category.selected = !category.selected
this.$emit('selectcategory', category)
}
},
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
})
}
}
}

0 comments on commit 9a2a7f8

Please sign in to comment.