reorderd code
This commit is contained in:
@@ -21,11 +21,15 @@ export default {
|
||||
props: {
|
||||
columns: {
|
||||
type: Array,
|
||||
default: [ ]
|
||||
default() {
|
||||
return [ ];
|
||||
}
|
||||
},
|
||||
rows: {
|
||||
type: Array,
|
||||
default: [ ]
|
||||
default() {
|
||||
return [ ];
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="Navigation">
|
||||
<ul>
|
||||
<li v-for="(e, i) in navItems" :key="i">
|
||||
<li v-for="(e, i) in items" :key="i">
|
||||
<router-link :to="e.to">{{ e.name }}</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -9,42 +9,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Axios from 'axios';
|
||||
|
||||
export default {
|
||||
name: "Navigation",
|
||||
props: [
|
||||
'src',
|
||||
'items'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
navItems: []
|
||||
props: {
|
||||
items: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [ ];
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.items) {
|
||||
this.navItems = this.items;
|
||||
return;
|
||||
}
|
||||
// only load if no items are given
|
||||
Axios.get(this.src)
|
||||
.then(results => {
|
||||
if ( !Array.isArray(results.data) ) {
|
||||
alert('invalid data in: ' + this.src);
|
||||
return;
|
||||
}
|
||||
this.navItems = results.data;
|
||||
})
|
||||
.catch(error => {
|
||||
alert('error loading ' + this.src + ': ' + error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.Navigation li a {
|
||||
color: orange;
|
||||
}
|
||||
</style>
|
||||
</script>
|
||||
@@ -41,7 +41,6 @@ export default {
|
||||
methods: {
|
||||
add() {
|
||||
this.rows.push({'prop1': 'test'});
|
||||
this.$store.commit('increment');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user