8 ms·
I think what he means is why not use ++ in the click handler. We don't need a function to increment something. Standard HTML, onclick="var++"
by cremp 7y ago
I think what he means is why not use ++ in the click handler. We don't need a function to increment something.
Standard HTML, onclick="var++"
- ry4nolson 7y agoNo, I think he's referring to the fact that the function increment is called by interpreting the string "increment".
- aliveupstairs 7y agoyou can do exactly that, they just wanted to showcase the methods option. often you would switch true to false doing: `@click="isSomething = !isSomething"`
- cooperadymas 7y agoExactly this. Template directives support a lot of JS functionality (while not encouraging it, like JSX does). That said, except in rare, extremely simple cases I still prefer wrapping that logic in a computed property or method, as it will inevitably grow more complex later.