one small ande strong state manage for miniprogram
npm install micro-reaction-miniprogram
import { createStore, observable } from "micro-reaction-miniprogram"
const store = observable({
credits: {
count: 0
}
});
export default createStore('home', store)
import homeStore from "../../store"
import { mapToData } from "micro-reaction-miniprogram"
const connect = mapToData((store) => ({ count: store.credits.count }), 'home')
Page(connect({}))
<button class="btn" type="primary" bindtap="onTap">Add</button>
Page(connect({
onTap(e) {
homeStore.credits.count++
},
onJump(e) {
wx.navigateTo({
url: "/pages/mine/mine"
})
}
}))