我正在用Typescript和React编写前端应用程序,并且正在使用MUI。我的表单具有以下代码:
<TextField
label="Password"
value={this.state.password}
placeholder="Choose a password"
type="password"
onChange={(event: any) => this.setState({
password: event.target.value
})}
onBlur={console.log('here')}
error={this.state.passwordError}
/>
使用此代码,每次我单击键时,onBlur
都会被触发。难道我不应该在离开表格时就开除?
答案 0 :(得分:0)
查看declare @sql varchar(8000);
declare @dt date = '20170101';
while @dt < cast('20190901' as date)
begin
set @sql = 'insert into Master (userid, month, zip)
select
coalesce(u.userid, m.userid),
''' + convert(char(6), @dt, 112) + ''',
coalesce(u.zip, m.zip)
from '
/* change this expression as needed */
+ 'ZipUpdate'
+ convert(varchar(3), datediff(month, '20170101', @dt) + 1)
+ ' u full outer join Master m
on m.userid = u.userid and m.month = ''' +
+ convert(char(6), dateadd(month, -1, @dt), 112) + '''
where u.month = ''' + convert(char(6), @dt, 112) + ''';'
set @dt = dateadd(month, 1, @dt);
select @sql;
end
功能将很有帮助。看起来您似乎不想传递任何东西,因此只需将行onblur
更改为onBlur={this.onblur()}
就可以解决问题。
但是,如果您的函数看起来像这样
onBlur={this.onblur}
然后,您应该将上下文绑定到该上下文(“ this”)。相反,我建议去
onblur() {
...
}
将已绑定上下文。