Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dva tip #2

Open
jnotnull opened this issue Apr 14, 2017 · 0 comments
Open

dva tip #2

jnotnull opened this issue Apr 14, 2017 · 0 comments

Comments

@jnotnull
Copy link
Owner

jnotnull commented Apr 14, 2017

  1. 在初始化模型setup中获得url参数
 subscriptions: {
   setup({ dispatch, history}) {
     history.listen((url, state) => {
       if (pathToRegexp('/static/room/ctrlmemberdetail').test(url.pathname)) {
         dispatch({type:'initData', payload: {chatroom_id: url.query.chatroom_id, wechat_id: url.query.wechat_id}});
       }
     });
   }
 }, 
  1. 本地开发请求支持跨域,proxy.cofig.js中增加如下:
module.exports = {
  '/scrm/chat/*': 'http://192.168.5.46:8080/'
};
  1. jsx支持calc
style={{width: 'calc(100% - 20px)', marginLeft: "20px"}}
  1. 解决less中calc冲突
left: e("calc(50% - 70px)");
  1. 支持绝对路径引入组件
webpackConfig.resolve = {
    modulesDirectories: ['node_modules', 'app']
  };
  1. effects中在回调中执行其他effects
subscriptions: {
        setup({ dispatch, history, state, props }) {
            history.listen((query, state) => {
                dispatch({ type: 'initData', payload: { query, namespace, dispatch } });
            });
        }
    },
    effects: {
        initData: [function*({ payload }, { put, call, select }) {
            
            // 执行回调
            let callback = function(params){
                payload.dispatch({ type: 'querysiteinfo', payload: { site_id: params.site_id, origin: params.payload } });
                payload.dispatch({ type: 'querypostdetail', payload });
            };

            yield put({ type: 'querynavdata', payload: { query: payload.query, namespace, callback } });
        }, { type: 'takeLatest' }],

    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant