Usage of exact and strict props

前端 未结 2 1290
深忆病人
深忆病人 2021-02-02 13:50

I am working with React-Router in React-JS:

The is an built in component and have two different props: exact and strict

2条回答
  •  旧时难觅i
    2021-02-02 13:59

    Use case 1

    If you use exact and strict together, then the location.pathname will only match exactly as provided in path props.

    Example:

    
    

    Will only match /one but not /one/ and /one/two.

    Example:

    
    

    Will only match /one/ but not /one and /one/two.

    Use case 2

    If you use only strict, then the location.pathname will match which have trailing slash.

    Example:

    
    

    Will match /one/ and /one/two but not /one.

    Use case 3

    If you use only exact, then the location.pathname will match exact location path.

    Example:

    
    

    Will match /one or /one/. The exact props doesn't care for trailing slash. But it will not match /one/two.

提交回复
热议问题