redux2miniapp
v0.0.2
Published
小程序接入redux
Downloads
4
Readme
redux2mini
小程序接入redux
使用
module/store
import {createStore, combineReducers} from 'redux';
import {createConnect} from 'redux2miniapp';
import count from './count';
const reducers = combineReducers({
count,
});
const store = createStore(reducers);
export const connect = createConnect(store);
pages/message.js
import {PageWrapper} from 'redux2miniapp';
import {connect} from '../models/store';
import {updateCountAction, clearCountAction} from "../models/count";
const mapStateToProps = (state) => ({
count: state.count,
});
PageWrapper({
mixins: [connect.page(mapStateToProps)],
onLoad(query) {
console.log(query);
},
add() {
this.dispatch(updateCountAction(++this.data.count.count));
},
sub() {
this.dispatch(updateCountAction(--this.data.count.count));
},
clear() {
this.dispatch(clearCountAction());
}
});