React 获取 url 参数传值页面

 handleSubmit = e => {
    e.preventDefault();
    const { dispatch, form } = this.props;
    const isNewRecord = this.props.isNewRecord;

    // 获得URL参数
    const query_params = new URLSearchParams(this.props.location.search);
    const department_id = query_params .get('department_id');

    form.validateFields((err, values) => {
      if (!err) {
        const formVlaue = {
          ...values
        };
        console.log("formVlaue",formVlaue);
        if (isNewRecord) {
          dispatch({ type: "department/userEdit", payload: { department_id:department_id,...formVlaue } });
        }
      }
    });
  };
发布了50 篇原创文章 · 获赞 7 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/xh_960125/article/details/86311677