1.3.0 • Published 5 years ago

yzf-react-storage v1.3.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

完整压缩版-欢迎使用(45 kB)

** 版权属于yzflhez@126.com

react 数据管理组件;参考dva

~ npm install yzf-react-storage --save

~ import { dva, connect } from 'yzf-react-storage';

index.jsx 文件

class App2 extends React.Component {

constructor(props, context) {

super(props, context);

this.state = {

//

};

}

componentDidMount() {

console.log(this.props)

const {index, dispatch} = this.props;

setTimeout(() => {

dispatch({

type: 'index/loadFn',

payload: '323232'

})

}, 3000)

}

render() { // 活动效果监测与分析 / 辅助活动方案决策 / 圈人、圈店、圈券、圈商品

const { index } = this.props;

console.log(index)

return (

21211212

);

}

}

const stateFn = (state) => {

return state;

}

const App3 = connect(App2, stateFn);

class App extends React.Component {

constructor(props, context) {

super(props, context);

this.state = {

//

};

}

render() { // 活动效果监测与分析 / 辅助活动方案决策 / 圈人、圈店、圈券、圈商品

const { visible } = this.state;

return (

21

);

}

}

import myModel from './model.jsx';

const AppD = dva();

model.jsx

export default {

namespace: 'index',

state: {

// index

loadData: '21',

},

effects: {

async loadFn({ payload, state }, { call, put }) { #### 登录

// state 所以存储空间

const loadAjax = () => {

return new Promise((res, rej) => {

setTimeout(() => {

res(32)

}, 1000)

})

}

console.log(payload)

const Data = await call(loadAjax, payload);

console.log(payload)

await put({

type: 'save',

payload: {

loadData: payload

}

});

},

},

reducers: {

save(state, action) {

return {...state, ...action.payload};

},

},

};

AppD.model(myModel);

ReactDOM.render((), document.getElementById('react-content'));

ReactDOM.render({App}, document.getElementById('react-content'));

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago