1. 程式人生 > >使用路徑傳值

使用路徑傳值

1、第一種方法

this.props.props.history.push({pathname:'/insurancment/onlinebe',state:{ url:this.state.onlineUrl }});//這個方法路徑中是不會顯示出這個url的
  取值的時候:(會在props裡面)
this.state = {
src:this.props.url,
}

2、但是使用:

this.props.history.push(
`/Persment/departmet/PersonionNav?perId=${record.perId}`
);////這個裡面的perid及後面的值是直接展示在路徑上面的
這樣取值:queryString.parse(this.props.location.search).perId;

//注意:需要使用queryString.parse對值進行物件處理,不然取到的是空(因為this.props.location.search取到的值會是?perId=111)