如何在reactjs上检测Esc按键?与jquery类似的事情
$(document).keyup(function(e) {
if (e.keyCode == 27) { // escape key maps to keycode `27`
// <DO YOUR WORK HERE>
}
});
Run Code Online (Sandbox Code Playgroud)
一旦检测到,我想传递信息向下组件.我有3个组件,其中最后一个活动组件需要对退出键按下做出反应.
当组件变为活动状态时,我正在考虑进行一种注册
class Layout extends React.Component {
onActive(escFunction){
this.escFunction = escFunction;
}
onEscPress(){
if(_.isFunction(this.escFunction)){
this.escFunction()
}
}
render(){
return (
<div class="root">
<ActionPanel onActive={this.onActive.bind(this)}/>
<DataPanel onActive={this.onActive.bind(this)}/>
<ResultPanel onActive={this.onActive.bind(this)}/>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
以及所有组件
class ActionPanel extends React.Component {
escFunction(){
//Do whatever when esc is pressed
}
onActive(){
this.props.onActive(this.escFunction.bind(this));
}
render(){
return (
<input onKeyDown={this.onActive.bind(this)}/>
)
}
}
Run Code Online (Sandbox Code Playgroud)
我相信这会奏效,但我认为这更像是回调.有没有更好的方法来处理这个?
我根据这里给出的指令安装了sqlplus
sqlplus 'username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.100)(PORT=1521))(CONNECT_DATA=(SID=ORCL)))'
Run Code Online (Sandbox Code Playgroud)
这给了我错误
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jul 10 16:10:38 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-21561: OID generation failed
Enter user-name:
Run Code Online (Sandbox Code Playgroud)
这个问题的解决方案是什么?
PS:我已经添加了主机名,主机已经有了价值.
我使用快递3.x已经有一段时间了.命令行工具工作得很好.我决定更新到4.0,以便我可以尝试将旧应用程序与4.x兼容.
sudo npm install -g express
Run Code Online (Sandbox Code Playgroud)
安装表达完美,但是当我尝试
exprsss -h
Run Code Online (Sandbox Code Playgroud)
我明白了
bash: /usr/bin/express: No such file or directory
Run Code Online (Sandbox Code Playgroud)
有什么我做错了吗?
我正在使用generator-angular-fullstack.在我的本地机器上工作正常,我跑
grunt serve
Run Code Online (Sandbox Code Playgroud)
它启动服务器,但在VPS中它失败了
Warning: Command failed: xdg-open: no method available for opening 'http://localhost:9000'
Run Code Online (Sandbox Code Playgroud)
我已经安装了xdg-utils
$ sudo apt-get install xdg-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
xdg-utils is already the newest version.
Run Code Online (Sandbox Code Playgroud)
谁能解释一下我做错了什么?
我有以下代码。
interface MySecondInterface<A>{
type: A;
}
interface MyInterface {
(val1:string, val2:string): MySecondInterface<string>;
(): MySecondInterface<string>;
}
const myInterfaceFn: MyInterface = (value1: string, value2:string) => {
return {
type: value1 + value2
};
}
const myInterfaceFn2: MyInterface = () => {
return {
type: "Text"
};
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到代码。我收到错误
Type '(value: string) => { type: string; }' is not assignable to type 'MyInterface'.
Run Code Online (Sandbox Code Playgroud)
我将如何创建接口以支持两种方法签名?
基本上,函数的接口接受 2 个参数或不接受参数。我怎样才能做到这一点?
我在Mac中使用Atom。每当我按下alt+g up/down它时,它只会插入©符号,而不显示下一个差异。我做错了什么吗?
我有一个查询
Select age,qualification,sum(income) as total_income from employee
group by age,qualification;
Run Code Online (Sandbox Code Playgroud)
我想根据年龄和学历组别在total_income上找到排名。
例如
19|Grad|5000|rank:1
19|Grad|4000|rank:2
19|Grad|3000|rank:3
26|Grad|6000|rank:1
26|Grad|5000|rank:2
26|PosG|8000|rank:1
26|PosG|6000|rank:2
Run Code Online (Sandbox Code Playgroud)
我可以在Oracle中做到吗?我尝试了分区,但无法弄清楚。
如何将yield的值分配给变量?
function *foo() {
var x = yield "foo"
console.log(x);
}
let bar = foo()
bar.next() // returns {value: "foo", done: false}
bar.next() // returns {value: undefined, done: true}
//console.log logs undefined
Run Code Online (Sandbox Code Playgroud)
我的理解是您可以为变量赋值。
我想对不是库文件的文件(如require js)执行jshint
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var ignore = require('gulp-ignore');
gulp.task('jshint', function() {
gulp.src('./js/src/*.js')
.pipe(ignore.exclude('require.js'))
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
Run Code Online (Sandbox Code Playgroud)
这仍然需要js报告
C:\Work\neolivz\js\src\require.js: line 12, col 267, Too many errors. (32% scanned).
Run Code Online (Sandbox Code Playgroud)
任何的想法?
我有一些方法可以执行一些操作并调用回调,并且在一定时间后它也会执行相同的操作.
var myFunction = function(callback){
setInterval(function(){
var stuff;
//do some stuff
callback(stuff)
}, 3000);
}
Run Code Online (Sandbox Code Playgroud)
我可以将其更改为承诺功能吗?如果是,用户将如何调用该功能?我打算用蓝鸟图书馆.