我如何编写 React Spring 来更改边距?
How do I write a React Spring to change margin?
我尝试编写一个简单的反应 spring 来更改我的组件的边距,但它不起作用,div 只是使用 "from" 样式呈现。
const gradients = useSpring({
from: {
marginTop: '0'
},
to: {
marginTop: '-100vh'
}
})
return (
<animated.div style={gradients}>{some content}</animated.div>
)
花了我几个小时:你必须在 from
属性 上设置测量单位,即使它是零!
我尝试编写一个简单的反应 spring 来更改我的组件的边距,但它不起作用,div 只是使用 "from" 样式呈现。
const gradients = useSpring({
from: {
marginTop: '0'
},
to: {
marginTop: '-100vh'
}
})
return (
<animated.div style={gradients}>{some content}</animated.div>
)
花了我几个小时:你必须在 from
属性 上设置测量单位,即使它是零!