66 lines
1.3 KiB
Vue
66 lines
1.3 KiB
Vue
<template>
|
|
<div id="Base">
|
|
<h1>Base</h1>
|
|
<div class="results">
|
|
<ul>
|
|
<li v-for="item in items" v-bind:key="item.nid">
|
|
<Card :item="item"/>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
|
import Card from 'vuejs/components/Content/Card'
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
export default {
|
|
name: "Base",
|
|
data: () => ({
|
|
|
|
}),
|
|
computed: {
|
|
...mapState({
|
|
items: state => state.Search.items
|
|
})
|
|
},
|
|
methods: {
|
|
...mapActions({
|
|
newSearch: 'Search/newSearch'
|
|
})
|
|
},
|
|
created() {
|
|
// laucnh a search if params exists in url query
|
|
console.log('Base created() location',window.location);
|
|
let params = new URLSearchParams(window.location.search)
|
|
if(params.has('keys')){
|
|
this.$store.commit('Search/setKeys', params.get('keys'))
|
|
this.newSearch()
|
|
}
|
|
},
|
|
// beforeRouteEnter (to, from, next) {
|
|
// console.log('Base beforeRouteEnter');//, to, from, next);
|
|
// next()
|
|
// },
|
|
beforeRouteUpdate (to, from, next) {
|
|
console.log('Base beforeRouteUpdate', to, from, next);
|
|
this.$store.commit('Search/setKeys', to.query.keys)
|
|
this.$store.commit('Search/setTerm', to.query.term)
|
|
this.newSearch()
|
|
next()
|
|
},
|
|
components: {
|
|
Card
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
</style>
|