@netsells/nuxtjs-page-store
Store global data for a page which is cleared after changing page
Last updated a year ago by sam.boylett .
ISC · Original npm · Tarball · package.json
$ cnpm install @netsells/nuxtjs-page-store 
SYNC missed versions from official npm registry.

NuxtJS Page Store

A page data store which clears itself down between pages using nuxt middleware. Useful for passing data from the page to the layout.

Installation

yarn add @netsells/nuxtjs-page-store

Usage

This module is built on top of Vuex for reactivity.

Add to your nuxt config:

    modules: [
        '@netsells/nuxtjs-page-store',
    ],

set

Set the data object, is merged with existing data

this.$store.commit('pageStore/set', {
    title: 'Homepage',
    subtitle: 'Foo bar',
})

clear

Clear all the page data. Is called internally between pages

this.$store.commit('pageStore/clear');

getters


import { mapGetters } from 'vuex';

export default {
    name: 'my-layout',

    computed: {
        ...mapGetters('pageStore', ['get']),
    },
};

And in your template:

<div>
    <h1>{{ get('title') }}</h1>
    <h2>{{ get('subtitle') }}</h2>
    <nuxt />
</div>

Current Tags

  • 1.0.0                                ...           latest (a year ago)

1 Versions

  • 1.0.0                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |