Vue 設定腳本提前返回?
<p>是否可以在 Vue 設定腳本中提前返回? </p>
<pre class="brush:html;toolbar:false;"><template>
<div v-if="error || !data">Fallback content...</div>
<div v-else>Page content...</div>
</template>
<script setup lang="ts">
// ...
const { data, error } = await fetchApi()
// Early return here? E.g., if (error || !data) return
// ...
// Lots of code which doesn't need to run if error.
// E.g., calculation of variables only used in the page content.
// ...
</script>
</pre>
<p>注意:我來自 React 世界,對 Vue 還算陌生。 </p>