0

如何才能不通知该路由? My功能 “执行” 保持运行上链接react-router browserHistory.listen unlisten

const unlisten = browserHistory.listen(unlis); 

功能handleUrl(位置){ 常量NEWPATH = location.pathname一个IM cliking; (!newPath.includes(${id}))){ execute(); unlisten(window.location); } else unlisten(window.location); browserHistory.listen(handleUrl); handleUrl(window.location);

伊夫试图这样做:

browserHistory.push(`/search/${id}'); 

    const unlisten = browserHistory.listen(location); 

    function handleUrl(location) { 
    const newPath = location.pathname; 
    if (!newPath.includes(`${id})`) { 
     execute(); 
     unlisten(window.location); 
    else unliste; 
    browserHistory.listen(handleUrl); 
    handleUrl(window.location); 

,但没有运气

+0

我正在使用react-router 3.0并且无法更改它 – BeckiD

回答

0

找出如何解决它

let unlisten; 
 
    function handleUrl(location) { 
 
    const newPath = location.pathname; 
 
    if (!newPath.includes(`${id})`)) { 
 
     execute(); 
 
     unlisten(); 
 
    } 
 
    unlisten = browserHistory.listen(handleUrl); 
 
    handleUrl(window.location); 
 
}

相关问题