I defined mutations, in store.js and mutations, in store Module, isn"t it?
store.js
import Vue from "vue"
import Vuex from" vuex"
import moduleDashboard from". / modules/dashboard"
import axios from "axios"
Vue.use (Vuex)
export default new Vuex.Store ({
)state: {
userServerURL: "http://localhost:8080",
stationServerURL: "http://localhost:8080",
modules: {
dashboard: moduleDashboard
},
.
mutations: {
userToActive (state, inputData) {
this.state.loginSuccessUser = inputData.user
},
dashboard.js
const moduleDasboard = {
namespaced: true,
state: {
temperature: 0,
humidity: 0,
solar: 0,
atmosphere: 0,
.
mutations: {
temperature (state, value) {
state.temperature = value
},
humidity (state, value) {
state.humidity = value
},
solar (state, value) {
state.solar = value
},
atmosphere (state, value) {
state.atmosphere = value
}
method of calling module with commit
store.commit("temperature", temperatureValue)
store.commit("humidity", humidityValue)
store.commit("solar", solarValue)
store.commit("dashboard/atmosphere", { "atmosphere": atmosphereValue }, { root: true })
report an error
[vuex] unknown mutation type: temperature
[vuex] unknown mutation type: humidity
[vuex] unknown mutation type: solar
[vuex] unknown mutation type: dashboard/atmosphere