[Vuejs]-How to stop executing rest of setup script in Vue 3 composition api

1👍

It’s done as in any other place in JavaScript:

if (!isSomething.value) {
  router.replace('/somepage')
} else {
  // rest of setup script with a lot of code
}

That there’s "a lot of code" suggests that view component can be refactored to contain only the code that is essential for a route, the rest of the content can be extracted to nested component.

Leave a comment