Add Fruit data fetching beforeEnter route
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>Fruit Details</h2>
|
||||
<h2><span @click="() => this.$router.back()">◀</span> Details</h2>
|
||||
{{ this.fruit }}
|
||||
</div>
|
||||
</template>
|
||||
@@ -11,11 +11,6 @@ export default {
|
||||
name: "FruitDetails",
|
||||
computed: {
|
||||
...mapState(["fruit"])
|
||||
},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
next(async vm => {
|
||||
await vm.$store.dispatch("getFruit", to.params.id);
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user