safari axios then use window.location.href or location.href not work,but other explorer work

299 Views Asked by At
getSites = async (e, param) => {
    
      axios.get(`${Config.siteInfo}`).then(res => {
        if (res.status === 200 && res.data?.data) {          
          if (param === 'baidu') {
            var url = res.data.data[0].site
            window.location.href = url  //**not work in safari, but work in android or chrome (url value correct)**
          } 
        }
      }).catch(error => {
        console.log('getSites error:', error);
      });
  }
  

<div className="list">
  <div
    className="list-item"
    onClick={e => {
      this.getSites(e, 'baidu')

    }}
  >
    <span>
      <img src={logo} className="test" alt="" />
    </span>
    <span>{'测试'}</span>
  </div>
</div>

i don't know why using the 'window.location.href' or 'location.href' not working in safari, but work in android and other explorer, anyone knows? thanks

0

There are 0 best solutions below