此代码有什么问题。它可以在localhost上运行,但不能在实时Apache服务器上运行。我已经在json包上指定了主页,并且也有一个htaccess。它仅在活动服务器上为空。
app.js:
import React from 'react'
import {
Route,
Switch,
Redirect,
BrowserRouter as Router
} from 'react-router-dom'
import Login from './component/login/index'
function App() {
return (
<Router>
<Switch>
<Route exact path="/" component={Login} />
<Route path='/login' component={Login} />
</Switch>
</Router>
);
}
export default App;
组件index.js:
import React from 'react'
export default function Login(props) {
return (
<div>Login</div>
)
}
htaccess:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
依赖项:
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1",
},
答案 0 :(得分:0)
您可以将其添加到htaccess文件中,以将除图像,css和js文件请求之外的每个请求重定向到索引
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files (*.png)|*.png";
if (open.ShowDialog() == DialogResult.OK)
{
pictureBox2.Image = new Bitmap(open.FileName);
}
答案 1 :(得分:0)
尝试使用此useCallback
,
useCallback