vue中使用$set来实现对样式的自定义

很有趣,之前都是获取到dom然后去设置style,但是在vue中似乎有了一中新的方式。
demo:

dom:
<div :style="tooltipStyle">
	<p>{
    
    {
    
     tooltipContent.name }}</p>
    <p>{
    
    {
    
     tooltipContent.value | thousandBitFilter }}</p>
</div>

data: tooltipStyle: {
    
    top: 0,left: 0}
methods:
 setTimeout(function() {
    
    
 	this.$set(that.tooltipStyle, 'top', v.event.offsetY + 'px');},
  0);

猜你喜欢

转载自blog.csdn.net/weixin_43131046/article/details/126557615
今日推荐