过滤空输入

pull/7/head
cx 7 years ago
parent 912e13be5a
commit c04cd3bb03

@ -53,6 +53,13 @@ export class CommandComponent extends React.Component<{ commandStore: CommandSto
ref={o => { this.inputEl = o }}
placeholder="(请输入命令:)"
onKeyDown={this.inputKeyDown}
onChange={(e: React.FormEvent<HTMLInputElement>) =>
{
if (e.currentTarget.value == " ")
{
e.currentTarget.value = ""
}
}}
/>
</div>
</div>
@ -62,21 +69,26 @@ export class CommandComponent extends React.Component<{ commandStore: CommandSto
inputKeyDown = (e: React.KeyboardEvent<object>) =>
{
console.log(this.inputEl);
console.log(this.inputEl.value === "");
let inpValue: string = this.inputEl.value;
switch (e.keyCode)
{
case 13:
case 32:
this.props.commandStore.commands.push(this.inputEl.value)
this.inputEl.value = ""
if (inpValue != "")
{
this.props.commandStore.commands.push(inpValue)
inpValue = ""
}
break;
case 27:
this.inputEl.value = ""
this.props.commandStore.commands.push("取消.")
if (inpValue != "")
{
inpValue = ""
this.props.commandStore.commands.push("取消.")
}
default:
break;
}
console.log(e.keyCode);
// console.log(e.keyCode);
}
}

@ -175,7 +175,7 @@ html, body {
}
.scroll::-webkit-scrollbar {
width: 4px;
width: 15px;
}
.scroll::-webkit-scrollbar-track {

Loading…
Cancel
Save