• 关于react中遇到的问题记录说明


    5.el表达式

    dataSource = (userPage, orgList) =>
            userPage.map(item => {
                const org = orgList.find(org => org.orgId === item.ORG_ID);
                return {
                    ...item,
                    measuresName: item.MEASURES_NAME,
                    measuresId: item.MEASURES_ID,
                    unitedId: item.UNITED_ID,
                    orgId: item.ORG_ID,
                    //oUl.style.display == "block" ? oUl.style.display="none" : oUl.style.display="block"
                         unitedType: item.UNITED_TYPE =='black' ? '黑名单' : '红名单',
                    orgName: org ? org.orgName : item.ORG_ID,
                    key: item.MEASURES_ID
                };
            });

    4.react中自定义完成某个操作后,跳转到列表展示界面

           let promise;
                promise = this.props.personalService.updatePersonalMesages(myUser);//进行和后台交互的接口调用
           //完成交互后,进行通过修改浏览器链接地址的形式,切换路由到想要的界面去
           //Utils是自己封装的一个工具函数
                promise.then(data => {
                    Utils.pushLink(`/profile/main`);
                })

    3 If using forceUpdate() is discouraged, how should components react to change events in the model? (2017-05-11)

    // user.js
    
    export default class User extends EventEmitter {
        constructor(args) {
            super();
            this.id = args.id;
            this.isActivated = args.isActivated || false;
        }
        activate() {
            this.isActivated = true;
            this.emit('change');
        }
    }
    
    // UserView.jsx
    
    export default class UserView extends React.Component {
        componentDidMount() {
            this.props.user.on('change', this.onUserUpdate);
        }
        onUserUpdate() {
            this.forceUpdate();
        }
        render (
            var user = this.props.user;
            return (
                <div>
                    <span>User {user.isActivated ? 'is' : 'is not'} activated.</span>
                    <button onClick={user.activate()}>Activate</button>
                </div>
            );
        );
    }
    
    // app.js
    
    var user = new User({ id: 123 });
    ReactDOM.render(<UserView user={user} />, container);

    参考地址(需要翻墙):http://stackoverflow.com/questions/35617580/if-using-forceupdate-is-discouraged-how-should-components-react-to-change-eve

    2。2017-05-11   15:03:46

    <FormItem
                                            {...formItemLayout}
                                            label="性别"
                                                hasFeedback
                                        >
                                            {getFieldDecorator('sex', {
                                                initialValue: signUser.sex
                                            })(
                                                <RadioGroup>
    
                                                    <Radio key="M" value='M'>男</Radio>
                                                    <Radio key="F" value='F'>女</Radio>
                                                    <Radio key="U" value='U'>暂未设置</Radio>
                                                    <Radio key="F1" value='F1'>女</Radio>
                                                </RadioGroup>
                                            )}
                                        </FormItem>
    //去掉 hasFeedback 就没有狗狗了

    1.关于一个路由里面如果有重复的路由指向,路由加载不同的组件,那么测试结果是:系统会自动识别第一个路由指向的对应组件;

     <Route path="user/:id" name="用户详细" component={UserDetail}/>
    
    <Route path="user/:id" name="编辑用户" component={UserManagementDetail}/>
    
    //解决方案:
    
     <Route path="user/:id" name="用户详细" component={UserDetail}/>
    
    <Route path="users/:id" name="编辑用户" component={UserManagementDetail}/>
  • 相关阅读:
    php CI笔记
    Apache 2.4权限设置( you don't have permission to access / on this server Apache2.4)
    关闭浏览器时退出登录
    onunload 和 onbeforeunload都不执行
    apache ab压力测试工具需要用户登录才能测得时候怎么办?
    《国富论》读书笔记
    数据库设计技巧
    溜到不行。。
    Session和Cookie
    c#缓存
  • 原文地址:https://www.cnblogs.com/zxyun/p/6757412.html
Copyright © 2020-2023  润新知