Develop #8
@@ -38,7 +38,6 @@ export default {
|
|||||||
|
|
||||||
a {
|
a {
|
||||||
display: block;
|
display: block;
|
||||||
text-decoration: none;
|
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Vue from "vue";
|
|||||||
import VueRouter from "vue-router";
|
import VueRouter from "vue-router";
|
||||||
import Fruits from "@/views/Fruits.vue";
|
import Fruits from "@/views/Fruits.vue";
|
||||||
import Fruit from "@/views/Fruit.vue";
|
import Fruit from "@/views/Fruit.vue";
|
||||||
|
import store from "@/store/index";
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
@@ -14,7 +15,11 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: "/fruit/:id",
|
path: "/fruit/:id",
|
||||||
name: "FruitDetails",
|
name: "FruitDetails",
|
||||||
component: Fruit
|
component: Fruit,
|
||||||
|
beforeEnter: async (to, from, next) => {
|
||||||
|
await store.dispatch("getFruit", to.params.id);
|
||||||
|
next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<h2>Fruit Details</h2>
|
<h2><span @click="() => this.$router.back()">◀</span> Details</h2>
|
||||||
{{ this.fruit }}
|
{{ this.fruit }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -11,11 +11,6 @@ export default {
|
|||||||
name: "FruitDetails",
|
name: "FruitDetails",
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["fruit"])
|
...mapState(["fruit"])
|
||||||
},
|
|
||||||
beforeRouteEnter(to, from, next) {
|
|
||||||
next(async vm => {
|
|
||||||
await vm.$store.dispatch("getFruit", to.params.id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user