Setup routing for FruitDetails + fetch data on route transition + Fix fruit tests
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Fruit Details</h1>
|
||||
{{ this.fruit }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from "vuex";
|
||||
export default {
|
||||
name: "FruitDetails",
|
||||
computed: {
|
||||
...mapState(["fruit"])
|
||||
},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
next(async vm => {
|
||||
await vm.$store.dispatch("getFruit", to.params.id);
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
||||
Reference in New Issue
Block a user