代码之家  ›  专栏  ›  技术社区  ›  AnnaSm

Reactjs,如何比较props.location。字符串的路径名?

  •  2
  • AnnaSm  · 技术社区  · 9 年前

    在我的路由器中,我需要执行以下操作:

    if (props.location.pathname !== '/confirm') {
        // redirect to /confirm to force the user to confirm their email
    }
    

    console.log(props.location.pathname)
    

    /confirm
    

    props.location.pathname 值为“/confirm”的 /confirm

    2 回复  |  直到 9 年前
        1
  •  4
  •   Ali Tourani    7 年前

    三重等于 (或==)如下:

    if (stringTemp === 'desired string'){
          console.log('Equal');
        }
    
        2
  •  3
  •   Vikram Saini    9 年前

    if (props.location.pathname != '/confirm') {
    // redirect to /confirm to force the user to confirm their email
    

    }