I have below files and could not find the reason for warning "Classic mode for store/ is deprecated and will be removed in Nuxt 3". Everything works fine just getting that annoying warning.
modules/data.js file in store of nuxt.js.
const state = () => ({
loadedPosts: []
});
const mutations = {
setPosts(state, posts){
state.loadedPosts = posts;
}
};
const actions = {
setPosts(vuexContext, posts){
vuexContext.commit('setPosts', posts);
}
};
const getters = {
loadedPosts(state){
return state.loadedPosts;
}
};
export default {
state,
actions,
getters,
mutations
};
index.js file in store of nuxt.js.
import Vuex from 'vuex';
import data from "~/store/modules/data";
const createStore = () => {
return new Vuex.Store({
modules: {
data: {
namespaced: true,
...data
}
}
});
};
export default createStore;
...getters['data/loadedPosts']
/...dispatch('data/setPosts')
- Mr.Stark I am not feeling well.. I mean seriouslly this is an awfull syntax.. But you're 100% right that's the new deal with nuxt, big mistake.. – Hypophysis