diff --git a/resources/js/mixins/mergesQueryString.js b/resources/js/mixins/mergesQueryString.js index 3ea230c2..97f64a72 100644 --- a/resources/js/mixins/mergesQueryString.js +++ b/resources/js/mixins/mergesQueryString.js @@ -1,4 +1,5 @@ import queryString from 'query-string'; +import merge from 'merge'; export default { methods: { @@ -17,6 +18,23 @@ export default { var merged = queryString.stringify(mn); return window.location.pathname + (merged ? '?'+merged : ''); + }, + + query(options) { + options = merge({ + only: null, + }, options); + var c = queryString.parse(window.location.search); + + if (options.only !== null) { + for (var k in c) { + if (options.only.indexOf(k) < 0) { + delete c[k]; + } + } + } + + return Object.keys(c).length === 0 ? '' : `?${queryString.stringify(c)}`; } } }; diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index 325b2b82..06ae69ab 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -46,7 +46,7 @@