对于类组件,this.setState如果在事件处理程序内部则调用批处理.但是如果在事件处理程序之外更新状态并使用'useState'钩子会发生什么?
function Component() {
const [a, setA] = useState('a');
const [b, setB] = useState('b');
function handleClick() {
Promise.resolve().then(() => {
setA('aa');
setB('bb');
});
}
return <button onClick={handleClick}>{a}-{b}</button>
}
Run Code Online (Sandbox Code Playgroud)
它会useState马上渲染吗?或者它会是aa - bb然后aa - b呢?
可以使用css更改svg填充.但我没有设法制作动画.这是我的svg对象:
<svg version="1.1" id="tick" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 60 60" enable-background="new 0 0 60 60" xml:space="preserve">
<rect id="fill" x="21" y="26" width="60" height="60"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
而且,使用SASS:
@include keyframes(loading)
0%
fill: black
50%
fill: white
100%
fill: black
#fill
fill: white
@include animation(loading 3s infinite)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
你可以在这里看到问题:http://jsfiddle.net/vadirn/5pgXS/1/(仅使用-webkit-gradient).
HTML:
<table>
<tr>
<td>Row one, column one</td>
<td>Row one, column two</td>
<td>Row one, column three</td>
</tr>
<tr>
<td>Row two, column one</td>
<td>Row two, column two</td>
<td>Row two, column three</td>
</tr>
<tr>
<td>Row three, column one</td>
<td>Row three, column two</td>
<td>Row three, column three</td>
</tr>
</table>?
Run Code Online (Sandbox Code Playgroud)
SCSS:
$solid: 1px solid #444;
table {
border: $solid;
}
td, th {
border-right: $solid;
border-bottom: $solid;
}
tr {
background-image: -webkit-linear-gradient(left, #fff 0%, #444 50%, #ffffff 100%);
}
Run Code Online (Sandbox Code Playgroud)
…
在探索Medium的令人敬畏的标记时,发现了一种有趣的方法,通过使用border-radius:999em制作漂亮的药丸样式按钮.然而,这提出了一个问题:为什么边界半径:50%是椭圆而不是药丸?
这是一个实例:http://codepen.io/evergreenv/pen/ykpBA/

我可以通过navigator.mediaDevices.enumerateDevices()承诺获得'videoinput'类型的mediaDevices .
我可以通过navigator.mediaDevices.getUserMedia(constraints)承诺获得mediaStream .
constraints在userMedia中有两个视频轨道应该是什么样的?
css ×2
html ×2
animation ×1
constraints ×1
css3 ×1
getusermedia ×1
html-table ×1
react-hooks ×1
reactjs ×1
svg ×1
webrtc ×1