This is going to be a pretty quick post. Two weeks ago, we looked at how use watchers in Vue.js. This week I figured that we would look at computed properties and methods.
In the above example, we are taking Date.now() and outputting it to the screen four ways:
-
- Directly as
{{Date.now()}}
- As the variable
time
- As a computed value
- As a method
- Directly as
What’s the functional difference between the three? In this case, very little. 🙂
So, what if we bind to our component’s data instead of to Date.now()
?
So, now the value can actually update? 🙂
Have an idea of how to take this further? Feel free to drop a comment below.