From ef4cdd477644cfb4571e1d7eb3b9ef1d16a3ed54 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Tue, 22 Aug 2017 13:24:23 +0200 Subject: [PATCH] Add vuex-persistedstate example --- examples/vuex-persistedstate/README.md | 3 +++ examples/vuex-persistedstate/nuxt.config.js | 6 ++++++ examples/vuex-persistedstate/package.json | 12 +++++++++++ examples/vuex-persistedstate/pages/index.vue | 22 ++++++++++++++++++++ examples/vuex-persistedstate/store/index.js | 14 +++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 examples/vuex-persistedstate/README.md create mode 100644 examples/vuex-persistedstate/nuxt.config.js create mode 100644 examples/vuex-persistedstate/package.json create mode 100644 examples/vuex-persistedstate/pages/index.vue create mode 100644 examples/vuex-persistedstate/store/index.js diff --git a/examples/vuex-persistedstate/README.md b/examples/vuex-persistedstate/README.md new file mode 100644 index 0000000000..6827f6cf6a --- /dev/null +++ b/examples/vuex-persistedstate/README.md @@ -0,0 +1,3 @@ +# Nuxt.js with Vuex persisted state (localStorage) + +See https://github.com/robinvdvleuten/vuex-persistedstate diff --git a/examples/vuex-persistedstate/nuxt.config.js b/examples/vuex-persistedstate/nuxt.config.js new file mode 100644 index 0000000000..274248d91b --- /dev/null +++ b/examples/vuex-persistedstate/nuxt.config.js @@ -0,0 +1,6 @@ +module.exports = { + /* + ** We set `spa` mode to have only client-side rendering + */ + mode: 'spa' +} diff --git a/examples/vuex-persistedstate/package.json b/examples/vuex-persistedstate/package.json new file mode 100644 index 0000000000..7b83e11f23 --- /dev/null +++ b/examples/vuex-persistedstate/package.json @@ -0,0 +1,12 @@ +{ + "name": "nuxt-vuex-store", + "dependencies": { + "nuxt": "^1.0.0-rc6", + "vuex-persistedstate": "^2.0.0" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + } +} diff --git a/examples/vuex-persistedstate/pages/index.vue b/examples/vuex-persistedstate/pages/index.vue new file mode 100644 index 0000000000..8540d23c60 --- /dev/null +++ b/examples/vuex-persistedstate/pages/index.vue @@ -0,0 +1,22 @@ + + + diff --git a/examples/vuex-persistedstate/store/index.js b/examples/vuex-persistedstate/store/index.js new file mode 100644 index 0000000000..75a8434719 --- /dev/null +++ b/examples/vuex-persistedstate/store/index.js @@ -0,0 +1,14 @@ +import createPersistedState from 'vuex-persistedstate' + +export const state = () => ({ + counter: 0 +}) + +export const mutations = { + increment: (state) => state.counter++, + decrement: (state) => state.counter-- +} + +export const plugins = [ + createPersistedState() +]