You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Here is an example to implement the declaration of Computed Properties directly in the data object
createApp({ data() { return { message: 'Hello Vue!', birth_date: '2005', age: function(){ let today = new Date(); return today.getFullYear() - birth_date.toDate(); } } } }).mount('#app')
it is also possible to expand the idea and make it possible to get/set
createApp({ data() { return { message: 'Hello Vue!', birth_date: '2005', age: { get: function(){ let today = new Date(); return today.getFullYear() - this.birth_date; }, set: function(value){ let today = new Date(); this.birth_date = today.getFullYear() - value; } } } }).mount('#app')
as a result, such an implementation can be reached
` createApp({
data() {
return {
message: 'Hello Vue!',
Beta Was this translation helpful? Give feedback.
All reactions