Skip to content

for statement in inline handler #7238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JetLua opened this issue Nov 29, 2022 · 0 comments · Fixed by #7245
Closed

for statement in inline handler #7238

JetLua opened this issue Nov 29, 2022 · 0 comments · Fixed by #7245

Comments

@JetLua
Copy link

JetLua commented Nov 29, 2022

<script setup>
import { reactive } from 'vue'

const state = reactive({
  list: [1, 2, 3]
})

const {log} = console
</script>

<template>
  <h1>{{ msg }}</h1>
  <button @click="() => {
         for (const x of state.list) {
                  log(x) // output: undefined
        }         
  }">Click</button>
</template>

workaround:

  <button @click="() => {
         let x
         for (x of state.list) {
                  log(x) //output: 1, 2, 3
        }         
  }">Click</button>

SFC Playground

Originally posted by @JetLua in #7237

yyx990803 pushed a commit that referenced this issue Nov 9, 2023

Verified

This commit was signed with the committer’s verified signature.
primeos Michael Weiss
…ps (#7245)

close #7238
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants