如果用户不采取任何措施,我需要在13分钟不活动后显示超时警告模式,并在15分钟后结束会话.我需要使用reactjs来实现这一点.我在https://www.npmjs.com/package/react-timeout#react-classic-verbose检查了react-timeout ,但这没有帮助.如果有人知道如何做到这一点,请与我分享.
我有一个受控的 React 输入组件,我正在格式化输入,如 onChange 代码所示。
<input type="TEL" id="applicantCellPhone" onChange={this.formatPhone} name="applicant.cellPhone" value={this.state["applicant.cellPhone"]}/>
Run Code Online (Sandbox Code Playgroud)
然后我的 formatPhone 功能是这样的
formatPhone(changeEvent) {
let val = changeEvent.target.value;
let r = /(\D+)/g,
first3 = "",
next3 = "",
last4 = "";
val = val.replace(r, "");
if (val.length > 0) {
first3 = val.substr(0, 3);
next3 = val.substr(3, 3);
last4 = val.substr(6, 4);
if (val.length > 6) {
this.setState({ [changeEvent.target.name]: first3 + "-" + next3 + "-" + last4 });
} else if (val.length > 3) {
this.setState({ [changeEvent.target.name]: …Run Code Online (Sandbox Code Playgroud) 我正在使用 react-router 3.0.2 并尝试使用查询字符串配置路由器路径。这是我配置路由器的方式:
<Router history={browserHistory}>
<Route path="abc/login.do" component={LoginComponent}/>
<Route path="abc/publicLoginID.do?phase=def" component={VerifyComponent} />
<Route path="abc/publicLoginID.do?phase=ghi" component={ImageComponent}/>
<Route path="*" component={LoginComponent}/>
</Router>
Run Code Online (Sandbox Code Playgroud)
我知道这不是在“Route”中指定查询字符串 (?) 的正确方法。我如何确保每当用户在 url 中输入“ http://localhost:3000/abc/publicLoginID.do?phase=def ”时,“VerifyComponent”就会出现,当他输入“ http://localhost: 3000/abc/publicLoginID.do?phase=ghi " 在 url 中,"ImageComponent" 出现了。
我确实在这里检查了一些情况:react-router 匹配查询字符串和react-router 中的Querystring,但无法弄清楚如何使其工作。