'Vue 3: Composition API with external templates

So, I come from Angular world where by default we are separating view from business logic... and I don't like single file components, especially when they are getting bigger and convoluted.

Before in vue 2, I would have myComponent.vue with script tag and have it like so:

<template src="./myComponent.html"></template>

To call the view file... and it would work... all the methods were accessible

but now, if I use the setup way

<script setup lang="ts">
  const suggets = () => {
  }
</script>

<template src="./myComponent.html"></template>

I would get a typescript error that suggest was declared and never used...

Also for example: <carbon-search /> component would not work

Failed to resolve component: carbon-search If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.

Any good and elegant way to split the component view and business logic (and css)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source