1

たとえば、localhost と localhost/test の 2 つのページがあり、localhost には localhost/test へのリンクがあります。

localhost/test はリンクをクリックしてアクセスできますが、手動で localhost/test の URL を更新または入力すると返されます。

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

私のコードは次のようなものです:

import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute, Link, IndexLink, browserHistory } from 'react-router';
import session from 'express-session';
import $ from 'jquery';

const App = React.createClass ({
    render() {
        return (
            <div>
                Router lza.
                <ul>
                    <li><Link to="test">Test</Link></li>
                </ul>
            </div>
        );
    }
})

const App2 = React.createClass ({
    render() {
        return (<div>Router lza.aasss</div>);
    }
})

var routes = (
    <Router history={browserHistory}>
        <Route path="/">
            <IndexRoute component={App} />
            <Route path="/test" component={App2} />
        </Route>
    </Router>
)

ReactDOM.render(routes, document.getElementById("hello"))

どうすれば解決できますか?

Express 4 で解決しようとしましたが、「express」から Express をインポートすると報告されます

Uncaught TypeError: Cannot read property 'prototype' of undefined

したがって、エクスプレスセッションを試しましたが、使用方法の完全な例が見つかりません。多くの例には「app」と呼ばれる var がありますが、どのように定義されていますか? または、更新時にURLにアクセスできるようにする方法を教えてください。ありがとうございました。

4

0 に答える 0