Closed jdl2206 closed 3 years ago
Thanks for the good feedback)) Please look at the documentation on how to connect the plugin correctly. https://yarkovaleksei.github.io/vue2-storage/en/started.html
Thanks for your quick reply.
It works fine when I use version 5.0.0 of the vue2-storage plugin in vue with this configuration but it wouldn't work with version 6.1.3 of the vue2-storage plugin, so I changed my project back to the 5.0.0 version:
Vue.use(Vue2Storage, { prefix: 'atd_', driver: 'local', ttl: 60 60 24 * 1000 }) // 24 hour expiration
@jdl2206 Show me how you import the plugin version 6
I tried importing it the same exact way as I did for 5.0.0, but I got this webpack error: Class constructor Vue2Storage cannot be invoked without 'new'
import Vue2Storage from 'vue2-storage'
Vue.use(Vue2Storage, { prefix: 'atd_', driver: 'local', ttl: 60 60 24 * 1000 }) // 24 hour expiration
So that's when I tried changing the code to try to get around that error.
These are the versions of vue-cli in my project: "@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-router": "^4.5.12", "@vue/cli-service": "^4.5.12",
I gave you a link to the documentation above)) It will be right like this:
import { Plugin } from 'vue2-storage'
Vue.use(Plugin, {
prefix: 'atd_',
driver: 'local',
ttl: 60 * 60 * 24 * 1000
})
@jdl2206 Hi! Did my answer help you?
vue & vue2-storage version
"vue": "^2.6.11", "vue2-storage": "^6.1.3"
Reproduction Link
Steps to reproduce
use vue2-storage version 6.1.3 with a new vue-cli project
What is Expected?
It should work like version 5.0.0 worked.
What is actually happening?
Vue error: Class constructor Vue2Storage cannot be invoked without 'new'
So I changed the code to try to fix the error: Vue.use(new Vue2Storage(), { prefix: 'atd_', driver: 'local', ttl: 60 60 24 * 1000 }) // 24 hour expiration
and also this syntax: Vue.use(new Vue2Storage({ prefix: 'atd_', driver: 'local', ttl: 60 60 24 * 1000 }) // 24 hour expiration )
But then the $storage instance is not being instantiated correctly:
this.$storage cannot be found: Search.vue?9924:343 Uncaught (in promise) TypeError: Cannot read property 'remember' of undefined at _callee7$ (Search.vue?9924:343) at tryCatch (runtime.js?96cf:63) at Generator.invoke [as _invoke] (runtime.js?96cf:293) at Generator.eval [as next] (runtime.js?96cf:118) at asyncGeneratorStep (asyncToGenerator.js?1da1:3) at _next (asyncToGenerator.js?1da1:25) at eval (asyncToGenerator.js?1da1:32) at new Promise ()
at eval (asyncToGenerator.js?1da1:21)
at VueComponent.getAtSpecialistList (Search.vue?9924:343)
Thus, I changed the project to use vue2-storage version 5.0.0 and it works. BTW, great plugin!