Skip to content

How to create NUXT module with namespaced store #1

@mmoollllee

Description

@mmoollllee

Hey carepenny!

Thanks for your tutorial! It already helped me to set up nuxt-protected-mailto!

Now I'm trying to create a module from this cookie control message example, I created inside a other project. So it's not a module yet, but it's working already.

I already cloned your repo to nuxt-privacy-message. But it's nowhere near functioning yet, as I just started to put some code in.

Now I'm wondering...

  1. How to integrate and activate nuxt-vuex-localstorage as a dependency? I have to tell nuxt-vuex-localstorage which directory should be saved to the browser. How do I add the following part to my module, that was in nuxt.config.js before? Or does a user have to do this manually when using my module later?
    [
      'nuxt-vuex-localstorage',
      {
        localStorage: ['cookies'],
        mode: 'debug'
      }
    ],
  1. How do I use the store right within the cookieMessage component as I did before with the following? Or do I have to create helper-plugins the way it's done in your tutorial?
$store.state.cookies.collapsed == true
// or
this.$store.commit('cookies/saveSelection', newVal)

All the best,
hope you can help me :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions