Incorporating a lambda expression into the methods section of a Vuejs component has been a recent challenge for me.
Here's an example: I initiate alertyou()
and upon receiving the alert, I click okay. Subsequently, in the Vue developer tools, I notice that this.activated
transitions to true
.
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App',
activated: false
}
},
methods: {
alertme: () => { alert('Clicked'); this.activated = false; },
alertyou() {
alert('Alert You');
this.activated = true
}
}
}
Yet, upon clicking the button that triggers the alertme
lambda, I notice that after acknowledging the alert message, this.activated
remains true!
What perplexes me is whether this limitation pertains to lambdas. Are we only allowed to execute one statement per lambda? Or could this matter involve scope dynamics post the firing of an alert?