子路径中的React路由器在链接点击时不呈现

时间:2017-06-27 19:15:39

标签: reactjs url-rewriting react-router tuckey-urlrewrite-filter

我在子路径中有一个react应用程序(例如:domain.com/login),当我想去某个路径时,我点击了链接但是Route组件没有显示任何内容,当我在浏览器中写入时,它有效路由,确实家庭控制器显示确定,当我在域索引(即:domain.com)也正常工作时,问题是当我单击子路径中的链接。 我在java应用程序上使用react-router-dom 4。

import React from "react";
import {render} from "react-dom";
import {BrowserRouter as Router, Link, Route} from "react-router-dom";
const BasicExample = () => (
<Router basename="/login">
    <div>
        <ul>
            <li><Link to="/">Home</Link></li>
            <li><Link to="/about">About</Link></li>
            <li><Link to="/topics">Topics</Link></li>
        </ul>
        <hr/>
        <Route exact path="/" component={Home}/>
        <Route path="/about" component={About}/>
        <Route path="/topics" component={Topics}/>
    </div>
</Router>
)

const Home = () => (
<div>
    <h2>Home</h2>
</div>
)

const About = () => (
<div>
    <h2>About</h2>
</div>
)

const Topics = ({match}) => (
<div>
    <h2>Topics</h2>
</div>
)

export default BasicExample
render(<BasicExample/>, document.getElementById('login'));

这是我的urlrewrite.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
    <rule>
        <from>/login/.+</from>
        <to>/login</to>
    </rule>
</urlrewrite>

PD。抱歉,如果我的英语不好。

0 个答案:

没有答案