I am using a lambda expression within the methods section of a Vuejs component.
The example is below
I trigger alertyou()
and get the alert, click okay. Then in the vue developer tools I see this.activated
becomes 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
}
}
}
However, when I click the button that triggers the alertme
lambda. I get the alert message, click okay. But then this.activated stays true!
What is going on here is this a limitation with lambdas? Can you only trigger one statement per lambda? Or does this have to deal with scope once an alert is fired?