RE: Learning Vue.js - A Task List

You are viewing a single comment's thread from:

Learning Vue.js - A Task List

in javascript •  7 years ago  (edited)

Great work! Here's another way to eliminate the method but keep the button and click binding:

<button @click="task.completed = !task.completed">Toggle</button>

Here's the fiddle:

https://jsfiddle.net/harps116/2hmu4yyh/2/

This technique is pretty handy for toggle scenarios. Of course you could abstract the logic into a method for reuse and have a global toggle utility method which might be useful.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you. I think that this "demo app" idea of a Task List or Todo List is a good way to learn. I think I will create one for myself with a database backend as a way to learn how to put everything together.