zhetengbiji / mp-storage

小程序(兼容 mpvue) Storage 垫片,用于在各个小程序平台(兼容 Web)实现 localStorage、sessionStorage 全部 API
9 stars 8 forks source link

在小程序端引用后报“ uni is not defined ”错误 #1

Closed nicemorning007 closed 5 years ago

nicemorning007 commented 5 years ago

在微信小程序上使用该垫片。报出“ uni is not defined ”的错误。 应用了MpVue。我的配置是这样的: ` import Vue from 'vue' import Vuex from 'vuex' import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const store = new Vuex.Store({ state: { count: 0 }, mutations: { increment: state => { const obj = state obj.count += 1 }, decrement: state => { const obj = state obj.count -= 1 } }, plugins: [ createPersistedState({ storage: this.$localStorage }) ] })

export default store `

nicemorning007 commented 5 years ago

稍微做了修改可以使用了