0

I have an error in vuex store

error: 8:3 error Parsing error: Unexpected keyword 'new'.

// Vuex store
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);


export const store = {
  new Vuex.Store({
    state: {
      count: 0,
    },
    getters: {
      increment: (state) => {
        state.count += 1;
      },
    },
  });
}

1
  • Remove the curlies. store = new … Commented Aug 25, 2021 at 5:34

1 Answer 1

1

Try this, remove brackets and use syntax mentioned here

// Vuex store
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);


export const store =
  new Vuex.Store({
    state: {
      count: 0,
    },
    getters: {
      increment: (state) => {
        state.count += 1;
      },
    },
  });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.