如何使 link 在 React.Js 内部渲染中可点击?

How to make a link clickable in React.Js inside render?

如何在 React.Js 内部渲染中使 link 可点击?如果我单击 link,它会转到主页。我只想关注 link。 我的代码看起来像这样

              <tr>
                <td>IPFS Hash # stored on Eth Contract</td>

                <td><a href= "#">{"https://gateway.ipfs.io/ipfs/"+this.state.ipfsHash}</a></td>
              </tr>

我希望我理解你的问题,我想你正在寻找的是

  <tr>
     <td>IPFS Hash # stored on Eth Contract</td>
     <td><a href={"https://gateway.ipfs.io/ipfs/"+this.state.ipfsHash}>Click here to go to home page</a></td>
  </tr>

React 添加点击和重定向的方法是使用 Link 由 react-router-

提供

组件内部

import {Link} from 'react-router-dom;
class Parent extends React.Component{
    render(){
         <div><Link to="/home">Click here to go back to home page</Link></div>
    } 
}

在路由文件中

import React from 'react';
import {BrowserRouter as Router,Switch} from 'react-router-dom;
export class RoutingClass extends React.Component{
    render(){
        <Router>
            <Switch>
                <Route exact path="/home" component={Home} />
            </Switch>
        </Router>
    }
}