Reactsjs在某些路径上隐藏按钮

时间:2017-11-28 16:14:41

标签: reactjs routes react-router components show-hide

我有一个标题

const Header = () => (
  <header className="header">
    <h1 className="title">Sport shop</h1>
    <a href="/add" className="addBtn">Add a new shirt</a>
    <a href="/add" className="addBtn">back to homepage</a>
  </header>
);

这是一个常见的组件,但一旦我在路线'/ addshirt',我只想显示后退按钮。同样,当我在主页时,我只想显示“添加一个新的衬衫纽扣”

我起诉反应路由器

  <Router>
        <div className="inner">
          <Header />
          <Route exact path="/" component={home} />
          <Route exact path="/addShirt" component={AddShirt} />
        </div>
      </Router>

1 个答案:

答案 0 :(得分:1)

您可以使用相同的> head(opt1) sensitivity PRODUCT Revenue Quantity Profit cost norm_price norm_quant norm_prof change_prof change_quant change_price final_rev final_profit 1: 1 PRODUCT10000 563.04 2672 362.4716 0.31567063 0.8861575 0.402326322 0.7057182 0.5041516 0.3252316 1.3541611 0.3565244903 0.2295218855 2: 1 PRODUCT10001 9291.51 73978 6733.7684 0.31664415 1.1502735 0.402326322 0.4348806 0.8172296 0.7712255 1.0432302 0.4627852903 0.3353910144 3: 1 PRODUCT10002 15015.24 26048 13071.6165 0.13677461 1.1000000 0.092918066 0.4284446 5.0127018 4.7870351 1.0410391 0.1022098726 0.0895010400 4: 1 PRODUCT10003 620.54 112 565.3049 0.08194787 1.1000000 0.213661313 0.4528317 2.5270022 2.0818090 1.1948142 0.2350274446 0.2175183551 5: 1 PRODUCT10004 2154.00 1000 1605.0000 0.48488348 1.3000000 0.000464435 0.2933202 445.5299526 774.8137110 0.6833333 0.0006037655 0.0003785686 6: 1 PRODUCT10005 1390.00 10000 1028.2500 0.27736785 1.2000000 0.001318247 0.3711992 357.1610035 305.1980502 1.1259494 0.0015818960 0.0012162568 组件!仅当<Route />与给定路径匹配时,它才会呈现传递的componentrender函数。

尝试类似

的内容
<Route />

同时查看路由组件的the docs