reactjs - how to go to other page when 2 selected of selecbox checked in react?
问题描述
这是我的代码:
这个app root
反应
import React, { Suspense, lazy } from 'react';
import { Link, BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import './App.css';
const Home = lazy(() => import('./screen/home/Home'));
const About = lazy(() => import('./screen/about/About'));
function App() {
return (
<Router>
<Suspense fallback={<div>Loading...</div>}>
<Switch>
<Route exact path="/" strict component={ Home }/>
<Route path="/about" strict component={ About }/>
<Route path="*" strict component={ () => " 404 Page Not Found " } />
</Switch>
</Suspense>
</Router>
);
}
export default App;
我的render
组件像这样返回
render() {
return(
<input type="checkbox"
id="a"
name="cheker"
value="a"
/>
<label for="a">A</label>
<input type="checkbox"
id="b"
name="cheker"
value="b"
/>
<label for="b">A</label>
<input type="checkbox"
id="c"
name="cheker"
value="c"
/>
<label for="c">A</label>
)
}
}
我component
和handlecheked
喜欢这个
export default class Home extends Component{
constructor(props){
super(props);
this.state = {
postData: [], // i use this for json data
checked: false,
isLoading: true
}
}
handlecheked= () => {
// this for handle if 2 checked selecbox will go to about page
}
解决方案
推荐阅读
- java - Spring boot @Async 注解抛出 LazyInitializationException
- json - 如何将嵌套的 Json 数组反序列化为字典?
- outsystems - 在使用 OutSystems 平台开发的移动应用程序中从 API 响应创建动态 UI(输入表单)
- firebase - Delphi 对 Firebase 实时数据库的 POST 请求
- r - 合并三个因子,使它们的因变量在 R 中求和
- javascript - 将两个数组与对象进行比较并显示删除了哪个项目
- c++ - 使用快速排序在 C++ 中排序可视化器错误
- node.js - 错误:发送 NodeJS Mongoose 后无法设置标头?
- node-red - node-red 中“更新”的正确语法
- ruby-on-rails - “或”语句在 Rails 查询中不起作用