Witam, po wyświetleniu wszystkich postów chcę, po kliknięciu, przejść do tego konkretnego. W router link przekazuję id w taki sposób
<router-link :to="{ name: 'ShowPost', params: { id: item.id}}">
{{item.title}}
</router-link>
w vuex
const state = {
post: {}
}
const getters = {
post: state => {
return state.post
}
}
const actions = {
getPost({commit}, id) {
axios(`/post/view/${id}`)
.then(result => commit('POST', result.data.data))
}
}
const mutations = {
POST(state, post){
state.post = post
}
}
export default {
state,
getters,
actions,
mutations
}
i w komponencie Show.vue
import {mapGetters} from 'vuex'
export default {
data(){
return{
}
},
computed:{
...mapGetters({
post: 'post'
})
},
created(){
this.$store.dispatch('getPost')
}
}
konkretne dane chcę wyświetlić tak:
{{post.title}}
wszystko nie wyświetla błędów jednak nie wyświetla też danych ...