简体   繁体   中英

open window using react-router v4's this.props.history.push?

I know we can use a Link tag and pass in target="_blank" like

<Link to="/" target="_blank">Hello World</Link>

but I am having trouble finding out I can do that with this.props.history.push... I am using that to pass in a pathname and search string...

    let searchString = queryString.stringify({
      rangeEnd: data.programEnd,
    });

    this.props.history({
      pathname: `/machines/${machineId}`,
      search: searchString,
      target: "_blank // need something like this, not seeing it in docs
    });

History push changes address in the same window.

One option could be using window.open()

const url = `#/machines/${machineId}?${searchString}`;
window.open(url);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM