// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
// #endif
// #ifdef VUE3
import { createStore } from 'vuex'
const store = createStore({
// #endif
state: {
test:"测试数据"
},
mutations: {
test(state, provider) {
// uni.setStorage({
// key:"TEST_CONFIG",
// data:"测试数据",
// success: function () {
// console.log('success');
// }
// });
uni.setStorageSync('TEST_CONFIG', '测试数据');
}
},
getters: {
},
actions: {
}
})
export default store

- 发布:2021-10-12 11:06
- 更新:2021-10-14 21:05
- 阅读:760
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 20H2
HBuilderX类型: 正式
HBuilderX版本号: 3.2.9
第三方开发者工具版本号: 1.05.2107221
基础库版本号: 2.20.0
项目创建方式: HBuilderX
示例代码:
操作步骤:
直接运行
直接运行
预期结果:
在vuex中正常使用数据缓存相关api
在vuex中正常使用数据缓存相关api
实际结果:
使用报错导致程序运行不起来
使用报错导致程序运行不起来
bug描述:
在vuex中使用数据缓存相关api时报错app.js错误:TypeError: Cannot read property 'getSystemInfoSync' of undefined ,导致程序运行不了。


依赖缺失问题参考这里:https://ask.dcloud.net.cn/question/132368
getSystemInfoSync 报错问题将会排查
-
-
邓琪昌 (作者)
微信小程序 vue3 中使用 hbx 3.2.10 alpha 版本添加依赖文件后getSystemInfoSync 报错问题已经没有出现了,但是出现了新的报错。
TypeError: Cannot convert undefined or null to object
at a.keys (<anonymous>)
at patch (vendor.js? [sm]:6268)
at ReactiveEffect.componentUpdateFn [as fn] (vendor.js? [sm]:6395)
at ReactiveEffect.run (vendor.js? [sm]:1979)
at setupRenderEffect (vendor.js? [sm]:6432)
at mountComponent (vendor.js? [sm]:6348)
at createComponent (vendor.js? [sm]:6466)
at $createComponent (vendor.js? [sm]:7718)
at Ui.attached (vendor.js? [sm]:7802)
at i.safeCallback (VM422 WAService.js:2)(env: Windows,mp,1.05.2110110; lib: 2.20.0)2021-10-15 09:09