前言:‘_blank’打开新窗口页面,state算内存传值,用<Link to={{pathname: url, state: data}}></Link>或者this.props.match.history.push(urlName, state)都失效
解决办法:
1:window.postMessage()
a.html
const newWindow = window.open(`b.html`, ‘_blank‘) newWindow.onload = () => newWindow.postMessage(data, window.origin)
b.html:
componentDidMount() { window.addEventListener(‘message‘, (event) => { console.log(‘我收到数据了!‘, event, event.data) }, false) }
待更新。。。。。