//實現(xiàn)一個點擊跳轉(zhuǎn)功能代碼: constructor(props){ super(props); this.clickFunc = this.clickFunc.bind(this); //由于ESlint原因,沒法利用bind在jsx里綁定事件 } clickFunc=(url)=>{ window.location.href = url; } //render 方法里 return ( <div className="linkWrap" onClick={this.clickFunc(url)}> //還是環(huán)境問題,這里的點擊跳轉(zhuǎn)鏈接,沒法用a標簽...., //所以寫了一個跳轉(zhuǎn)方法 </div> );問題:這樣一來只要頁面一加載就會自動執(zhí)行一次clickFunc方法,導致看不到原本的頁面,有沒有什么辦法,在實例化的時候不會執(zhí)行方法,并且可以綁定方法?
react里遇到一個鏈接跳轉(zhuǎn)問題
瀟湘沐
2019-03-14 18:15:38