我使用redux-form渲染下面的简单形式,它运行良好.现在,我想在一个更多的情况下禁用提交按钮:如果任何Field
一个有错误(即它meta.error
已设置).
从lokking到文档,我想周围的人不可能<form>
知道它的<Field>
组件是否有错误.也许任何人都有一个想法,如何解决它就像使用一样简单disabled={hasErrors || submitting || pristine}
const EditBlogEntryForm = ({ onSubmit, reset, handleSubmit,
pristine, submitting, ...rest }) => {
console.log('rest: ', rest);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<div className="form-group">
<Field name="title"
type="text"
component={renderField}
label="Titel"
className="form-control"
placeholder="Titel eingeben..." />
</div>
<div className="form-group">
<Field name="text"
component={renderTextArea}
label="Text"
className="form-control"
placeholder="Textinhalt eingeben..." />
</div>
<div className="form-group">
<Field name="image"
type="text"
component={renderField}
label="Bild-URL:"
className="form-control"
placeholder="Bildadresse eingeben..." />
</div>
<div>
<button type="submit" className="btn btn-default"
disabled={submitting || pristine}>
Blogeintrag speichern …
Run Code Online (Sandbox Code Playgroud) 这可能与 putty 无关,但它在那里非常明显:在 putty 中使用 Google 的 Inconsolata 字体(https://fonts.google.com/specimen/Inconsolata)会导致非常高的行间距:
我知道这与字体本身有关,因为使用“Consolas”和其他字体显示了差异。但我只是想知道,是否有人有解决方案在腻子中使用这种非常漂亮的字体?
我有一个简单的导航器组件,包含一些按钮和日期选择器子组件.现在我的想法是,我可以绑定keydown.arrowleft
整个div(具有100%高度和宽度的css样式)等.它的模板看起来像这样:
<div id="ck-navigator" (keydown.arrowleft)="decrementDate();
$event.preventDefault()" (keydown.arrowright)="incrementDate();
$event.preventDefault()">
<button (click)="decrementDate()" class="fa fa-2x fa-chevron-left">
</button>
<ck-date-picker [date]="date" (dateChange)="changeDate($event)">
</ck-date-picker>
<button (click)="incrementDate()" class="fa fa-2x fa-chevron-right"></button>
</div>
Run Code Online (Sandbox Code Playgroud)
我没有显示组件代码,这个问题无关紧要(afaik).这是有效的,但前提是我事先主动选择按钮或日期选择器(也称为控制元素).是否有可能将键绑定扩展到整个div(即,如果我只是点击网站上的某个地方).很抱歉我对DOM缺乏了解,并感谢任何正确方向的推动.
我只是偶然发现了这个漂亮的小型仓库,比较了几种编译和解释语言的简单递归fibonacci函数:https://github.com/drujensen/fib.这似乎很公平,因为它不会在任何地方进行任何优化技巧.我知道有更好的方法可以使用Go的功能,但我只是想知道,为什么Go似乎比其他编译和静态类型语言慢得多?我可以在我的机器上用11s确认它看起来与Go非常相似.
鉴于此代码模拟使用扇入模式获取 3 个 URL 的某些网站内容,并覆盖压缩频道:https : //play.golang.org/p/MSkRI7x4vz
for s := range r {
println(s)
}
Run Code Online (Sandbox Code Playgroud)
这很好用,但我想使用整体超时信号通道,所以我尝试在这样的 for 循环中使用选择:https : //play.golang.org/p/LjDoIc0j-z
totalTimeout := time.After(300 * time.Millisecond)
loop:
for {
select {
case s := <-r:
fmt.Println(s)
case <-totalTimeout: // signaling usage of a channel
fmt.Println("Timed out")
break loop
}
}
}
Run Code Online (Sandbox Code Playgroud)
这表现得不好:在输入通道关闭后,来自扇入的压缩通道被关闭。但是现在读取零值直到超时有效发生。当我阅读http://www.tapirgames.com/blog/golang-channel或规范https://golang.org/ref/spec#Close 时,似乎从关闭的频道接收“从不阻塞”并因此返回零值。我只能猜测,范围检测关闭,选择不能,因为它的条件是从本身的通道读取。
我可以这样爆发
case s := <-r:
if s == "" {
break loop
}
fmt.Println(s)
Run Code Online (Sandbox Code Playgroud)
是否有另一种方法来停止获取空值,或者这是在 for 循环中使用 select 的正确惯用方法?
go ×2
angular ×1
css ×1
fibonacci ×1
fonts ×1
for-loop ×1
html ×1
performance ×1
putty ×1
react-redux ×1
reactjs ×1
redux ×1
redux-form ×1