LWC - First Look - Handle DOM Events
Brett M. Nelson - Monday, January 28, 2019
What I want to do is handle when somebody clicks.
It would help if I spelled it correctly. When somebody clicks on this
h1 one I wanted to
I wanted to call a method called
handleClick on my class
h1 I've assigned to an
First thing I'm going to do is saying that it was clicked in the console
To get rid of the square braces call
Now this isn't gonna be terribly exciting. So let's also change the value of our label.
I'm going to split it and I'm going to reverse it. Then we will join it with no spaces or no characters, and I should definitely reassign it to itself.
So what I'm doing here is I take the label or split it on every character into an array and I reverse the array and then I rejoined it into a string and reassign it back to the label. Once deployed out.
Now we can refresh the page now if I click on it, it reverses.
We can keep clicking an arrow key person.
But what if we want to handle another kind of event
instead of handling and
onclick method, what's handle
Now as my when my mouse goes over it, it reverses.
That’s it for now.
Remember to sign up for The Weekly Stand-Up! and you can get updated with any new information we have on WIPDeveloper.com.