- yarn add radish_wx_mini_store
- 初始化,在app.js里面初始化需要的方法
const wx_mini_store = require('radish_wx_mini_store');
const aldstat = require('./utils/ald-stat/ald-stat');
App({
store: wx_mini_store.store,
create: wx_mini_store.create,
regeneratorRuntime: wx_mini_store.regeneratorRuntime,
aldstat,
onLaunch() {
// 初始化项目
const params = {
default: require('./utils/config/default'),
develop: require('./utils/config/develop'),
trial: require('./utils/config/trial'),
prod: require('./utils/config/prod'),
}
wx_mini_store.init(params);
},
// 其他小程序跳转回来有传递参数只在这里触发
onShow(options) {
try {
const extraData = options.referrerInfo.extraData;
} catch (error) {
console.log(' onshow error ', error);
}
}
})
// 小程序主入口 授权 中转页面
const store = getApp().store;
const create = getApp().create;
const regeneratorRuntime = getApp().regeneratorRuntime;
create(store, {
data: {
focus: false
},
onLoad() {
this.store.watch(this.watch());
this.store.data.userInfo = {
name: 'radish',
age: 10
};
},
changeValue() {
this.store.data.userInfo.name = 'kkk';
this.update();
},
watch() {
return {
'userInfo': (value) => {
console.log('userInfo 数据发生改变', value);
}
}
},
});
网友评论