Why does the template's ordinary function inside script setup
looks reactive?
#6336
-
please see demo |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
If you don't need reactive. Please don't implement it |
Beta Was this translation helpful? Give feedback.
-
Hi! There is no difference between So it is only natural that Have a nice day :) |
Beta Was this translation helpful? Give feedback.
-
This is the expected behavior. |
Beta Was this translation helpful? Give feedback.
-
some references: https://v2.vuejs.org/v2/guide/computed.html#Computed-Caching-vs-Methods |
Beta Was this translation helpful? Give feedback.
Hi!
There is no difference between
methods
andcomputed
in becoming reactive itself.However, computed is better in the sense that it is recomputed only when there is a change in the reactive element on which it depends.
So it is only natural that
fn()
is reactive in your demo.Have a nice day :)