Subscribe on changes!

computed in class property can not update

avatar
Feb 24th 2022

Version

3.2.31

Reproduction link

sfc.vuejs.org/

Steps to reproduce

see link, computed in {{}} is worked, but in :class="{}", did not work. maybe is not a bug, but I want to save computed value in a Object, and use it in another component

What is expected?

computed value could update

What is actually happening?

computed value could not update

avatar
Feb 24th 2022

refs nested in plain, nonreactive objects are not unwrapped.

<h1 :class="{ active: a.isActive.value }">{{ a.isActive.value }}</h1>
avatar
Feb 24th 2022

This is by design, you should use cmptuedRef.value, or unref(computedVal) instead,. You may think this is weird, but automatically unref will definitely increase the overhead for template rendering.

avatar
Feb 24th 2022

It worked, thanks