123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import React from 'react';
- import { connect } from 'react-redux';
- import { BrowserRouter, Route,Link } from 'react-router-dom';
- import { actionCreators } from './store';
- class lock_count extends PureComponent {
-
- getListArea() {
- const { list, menu } = this.props;
- menu;
- if (true) {
- return (
- <div>
- {
- list.map((item) => {
- return <span className='ispan' type="text" key={item} >{item}</span>
- })
- }
- </div>
- )
- } else {
- return null;
- }
- }
- render() {
- //const { inputValue, handleInputFocus,handleInputChange, menu, list } = this.props;
- return (
- <div>lock_count</div>
- );
- }
- //组件即将要被挂在的时候执行的方法--
- componentDidMount(){
- //逻辑代码可以写在mapDispathToProps里 this.props.方法
- // axios.get('/api/submenuList.json').then((res) => {
- // const data = res.data;
- // dispatch(changeList(data.data));
- // }).catch(() => {
- // console.log('error');
- // })
- }
- }
- /**
- * store里的数据映射到这个组件里的state
- * @param {*} state
- */
- const mapStateToProps = (state) => {
- return {
- //menu: state.submenu.menu
- menu: state.getIn(['submenu', 'menu']),
- list: state.getIn(['submenu', 'list']),
- inputValue: state.getIn(['submenu', 'inputValue']),
- }
- // return {
- // focused: state.getIn(['header', 'focused']),
- // list: state.getIn(['header', 'list']),
- // page: state.getIn(['header', 'page']),
- // totalPage: state.getIn(['header', 'totalPage']),
- // mouseIn: state.getIn(['header', 'mouseIn'])
- // }
- }
- /**
- * 要改变store里的内容需要调用dispatch方法
- * @param {*} dispatch
- */
- const mapDispathToProps = (dispatch) => {
- return {
- handleInputFocus(list) {
- // const action = {
- // type: 'aearch_focus'
- // };
- //发送给store--提取出action--避免发送重复的ajax请求
- (list.size === 0) && dispatch(actionCreators.getList());
- // if(list.size>0){
- // dispatch(actionCreators.getList());
- // }
- dispatch(actionCreators.searchFocus());
- },
- handleInputChange(ivalueElem){
-
- dispatch(actionCreators.changeInputValue(ivalueElem.value));
- },
- }
- }
- export default connect(mapStateToProps, mapDispathToProps)(lock_count);
|