useElementStyle
useElementStyle 用于将响应式对象同步到目标元素的 CSS 样式。
它使用 reactiveStyle 并将其绑定到目标。
参数
target
目标必须是一个元素 (SVG / HTML),或一个元素的引用。
如果目标引用被更新,当前的样式将会从新的元素样式中更新。
暴露
style
Style 是当前 target
Style Properties (样式属性)作为一个响应式对象。
当你更改一个值时,它会相应地更新元素样式属性。
stop()
Stop 函数会停止监听器,该监听器用于同步元素样式与响应式对象。
示例
const target = ref<HTMLElement>()
const { style, stop } = useElementStyle(target)
style.opacity = 0