使用Link时定位特定路由器?

时间:2018-02-08 02:25:03

标签: reactjs react-router

我有一个看起来像这样的应用程序:

<BrowserRouter>
  <Route path="/" component={Root} />
</BrowserRouter>

// Root.js
function Root() {
  return (
    <MemoryRouter>
      <Switch>
      <Route path="/" component={MemRoot} />
      <Route path="/bar">
        <Link to="/>To browser Root</Link>
      </Route>
    </MemoryRouter>
  );
}

现在当我点击Link时,它会更改MemoryRouter的网址,但我真的希望改变{{1}的网址}。

如何告诉BrowserRouter定位Link

1 个答案:

答案 0 :(得分:0)

好的,你可以这样做。请参阅demo

<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['filename']['name']); 
if(move_uploaded_file($_FILES['filename']['tmp_name'], $target_path)) {
echo "The file ".  basename( $_FILES['filename']['name']). 
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>