Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

javascript - Ionic 5 React page crashes on device when window location href has email

I have a ionic-refresher component, and in it i am trying to use window.location.href, and it works when i do not have any variables in the value, like this

window.location.href = '/tab1';

but it does not work when i do have variables, like this

window.location.href = '/listing/' + id

Any ideas on how to solve this?

What i have tried is window.open(), window.replace(), history.go(0), history.push().

Full code here

<IonRefresher slot='fixed' onIonRefresh={doRefresh} 
    pullFactor={0.5} pullMin={100} pullMax={200}>
    <IonRefresherContent></IonRefresherContent>
</IonRefresher>

function doRefresh(event: CustomEvent<RefresherEventDetail>) {
        
        // window.open("/listings/" + id.id, "_self")
        
        // history.push("/listings/" + id.id)
  
        // history.go(0)

      }

EDIT: It's able to catch the variables, but not email id specifically. I will make it work with user id instead of email id.

question from:https://stackoverflow.com/questions/65902138/ionic-5-react-page-crashes-on-device-when-window-location-href-has-email

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First Upon you will check that you define your path with id like <Route path="/listings/:id" component={listening}/> in App.js

then you will do

function doRefresh(event: CustomEvent<RefresherEventDetail>) {
      
     history.push(`/listings/${id.id}`)
        
  }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...