【小程序】使用uni-app搭建小程序环境--VueX

使用VueX 存储登录状态

问题一:在vue页面中使用 this.$store.dispatch('login',option)  没有任何报错  没有任何反应

问题二:在js中使用 this.$tore.state.userInfo  报错 Uncaught TypeError: Cannot read property '$store' of undefined

解决方案:

import store from '../store' 

const unserInfo = store.state.userInfo;

相关资料:uni-app 使用Vuex+ (强制)登录

原文地址:https://www.cnblogs.com/websmile/p/11943525.html