Skip to content

为微信小程序提供 redux computed/计算属性 的功能,优化this绑定

License

Notifications You must be signed in to change notification settings

jingyue0828/minapp-rct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minapp-rct · GitHub licensenpm version

minapp-rct 是一款小程序的功能扩展插件

  • Redux: 简单配置便可在小程序中使用 Redux.
npm 构建
npm i minapp-rct
API
//注册
use()
//连接页面
connect()
//连接组件
connectComponent()

在 App.js 中注册,具体配置及使用方式可查看例子.

// app.js
import { use } from 'minapp-rct'
import Store from '../../store/index'

use(Store)

App({})
Usage
import { connect } from 'minapp-rct';
import { actions } from '../../store/index';

const page = {
  // redux state
  state(state) {
    const { user } = state;
    return {
      userName: user.userInfo.userName,
    };
  },
  // redux actions
  actions(dispatch, state) {
    return {
      updateUserName(name) {
        dispatch(actions.user.setUserInfo({ userName: name }));
      },
    };
  },
  data: {
    example: 'example',
  },
  onLoad() {
    this.updateUserName('nameUpdated');
  },
};

Page(connect()(page));

About

为微信小程序提供 redux computed/计算属性 的功能,优化this绑定

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published