Element.animation 的打字稿型別是什么?如果我的代碼如下所示:
const ref = useRef<HTMLElement>( null );
useEffect( () => {
const animation: ANIMTATION_TYPE = ref.current.animate( SOME_ANIMATION );
}, []);
return (
<div ref={ref}>
Some Div
</div>
)
ANIMATION_TYPE 應該是什么?我試過 AnimationTimeline 但這不包括 .play 或 .pause 函式。
uj5u.com熱心網友回復:
如果您將滑鼠懸停animate(在 IDE 中的呼叫上,它應該會告訴您型別。我明白了:
(method) Animatable.animate(
keyframes: Keyframe[] | PropertyIndexedKeyframes | null,
options?: number | KeyframeAnimationOptions | undefined
): Animation
所以該方法的回傳型別是Animation.
它有一種play()方法并且可以像您期望的那樣作業。
const animation: Animation = document.getElementById('testing123')!.animate([])
animation.play() // works
操場
你可能不需要。TS 知道該方法的回傳型別,如果您只想使用該范圍內的值,這會很好:
const animation = document.getElementById('testing123')!.animate([])
animation.play() // works
操場
uj5u.com熱心網友回復:
影片將是影片型別。在這里您可以找到您需要的 animate 功能。
https://microsoft.github.io/PowerBI-JavaScript/interfaces/_node_modules_typedoc_node_modules_typescript_lib_lib_dom_d_.animatable.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/376230.html
