Fix: Fix all Pin filter load error

Route state chagne should be watched by child component.
This commit is contained in:
winkidney
2019-12-07 19:47:31 +08:00
committed by Isaac Bythewood
parent 83e85e9e7b
commit 47778d492e
5 changed files with 17 additions and 12 deletions

View File

@@ -148,6 +148,11 @@ export default {
},
},
},
watch: {
pinFilters() {
this.reset();
},
},
methods: {
shouldShowEdit(id) {
if (!this.editorMeta.user.loggedIn) {

View File

@@ -10,7 +10,7 @@ import PHeader from '../components/PHeader.vue';
import Pins from '../components/Pins.vue';
export default {
name: 'p-header',
name: 'Pins4Board',
data() {
return {
filters: { boardFilter: null },
@@ -20,16 +20,16 @@ export default {
PHeader,
Pins,
},
beforeRouteUpdate(to, from, next) {
this.filters = { boardFilter: to.params.boardId };
next();
},
created() {
this.initializeBoard();
},
beforeRouteUpdate(to, from, next) {
this.initializeBoard();
next();
},
methods: {
initializeBoard() {
this.filters.boardFilter = this.$route.params.boardId;
this.filters = { boardFilter: this.$route.params.boardId };
},
},
};

View File

@@ -24,12 +24,12 @@ export default {
this.initialize();
},
beforeRouteUpdate(to, from, next) {
this.initialize();
this.filters = { idFilter: to.params.pinId };
next();
},
methods: {
initialize() {
this.filters.idFilter = this.$route.params.pinId;
this.filters = { idFilter: this.$route.params.pinId };
},
},
};

View File

@@ -24,12 +24,12 @@ export default {
this.initializeTag();
},
beforeRouteUpdate(to, from, next) {
this.initializeTag();
this.filters = { tagFilter: to.params.tag };
next();
},
methods: {
initializeTag() {
this.filters.tagFilter = this.$route.params.tag;
this.filters = { tagFilter: this.$route.params.tag };
},
},
};

View File

@@ -24,12 +24,12 @@ export default {
this.initializeBoard();
},
beforeRouteUpdate(to, from, next) {
this.initializeBoard();
this.filters = { userFilter: to.params.user };
next();
},
methods: {
initializeBoard() {
this.filters.userFilter = this.$route.params.user;
this.filters = { userFilter: this.$route.params.user };
},
},
};