Я просто раскручиваюсь, используя Nuxt + Vuex. У меня очень простой component
& store
, но action
и getter
не идентифицируются vuex, и я не уверен, почему.
версии
# nuxt: 2.11
# vuex: 3.1.2
# vue: 2.6.11
store / properties. js
import axios from 'axios'
export const state = () => ({
properties: []
})
export const getters = {
allProperties: state => state.properties
}
export const actions = {
async fetchProperties ({ commit }) {
const response = await axios.get('http://localhost:3000/properties')
commit('setProperties', response.data)
}
}
export const mutations = {
setProperties: (state, properties) => (state.properties = properties)
}
страниц / свойств. vue
<template>
<div>
{{ allProperties }}
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
export default {
computed: mapGetters(['allProperties']),
created () {
this.fetchProperties()
},
methods: {
...mapActions(['fetchProperties'])
}
}
</script>
Выполнение этого приводит к
[vuex] unknown action type: fetchProperties
[vuex] unknown getter: allProperties
Почему getter
и action
не регистрируются или не идентифицируются?
Заранее спасибо.