Subscribe on changes!

Can not watch attrs with script setup

avatar
Jul 16th 2021

Version

3.1.4

Reproduction link

link

Steps to reproduce

Sorry, my English is poor. import useAttrs then watch attrs, watch method doesn't work. 监听 useAttrs 的值,当值发生变化后,监听不生效。使用已弃用的 defineProps 可以正常监听。

What is expected?

working fine

What is actually happening?

doesn't work

avatar
Jul 16th 2021

Attrs are non-reactive and can only be used in render functions. They are not a replacement of props. If you want to watch it reactively you need to use props.