Closed bediu closed 12 months ago
Consider the example:
<script setup>
import { ref } from 'vue'
if (false)
return
const msg = ref('Hello World!')
</script>
<template>
<h1>{{ msg }}</h1>
<input v-model="msg">
</template>
The msg
variable is declared after the return statement, so the template
can't access it since it is never defined.
What problem does this feature solve?
I want to use "return" or (or something different) to stop a script setup code from running.
In the example, the functions should only run if the dynamic list is bigger than 0.
I understand I can invert the ifs, but imagine if we didn't import these functions, but instead, you had to write the code directly. Suddenly you need your whole component's code wrapped around an if when all you can do is prevent the code from running under a specific condition.
What does the proposed API look like?