vue单文件组件如何拆分?
普通单文件组件:log.vue
            
            
              js
              
              
            
          
          <script setup lang="ts">
import { ref } from 'vue';
const index = ref<number>(1)
</script>
<template>
    <h1>{{ index }}</h1>
</template>
<style scoped>
h1 {
    color: red;
    font-size: 50px;
}
</style>目前情况
组长设计目的:
1.为了抽离逻辑内容,避免一个文件代码太多
2.逻辑代码使用class,可以抽离通用逻辑和工具到common,其他文件可以继承使用
拆分成两个文件:

log.hook.ts
            
            
              ts
              
              
            
          
          import { Ref, ref } from "vue";
export default class log {
    index: Ref<number>
  
    constructor() {
        this.index = ref(1)
    }
}log.vue
            
            
              ts
              
              
            
          
          <script setup lang="ts">
import logHook from "./log.hook";
const hook = new logHook()
</script>
<template>
    <h1>{{ hook.index }}</h1>
</template>
<style scoped>
h1 {
    color: red;
    font-size: 50px;
}
</style>缺点:
1.this.的问题.在log.hook.ts内部,写逻辑,都要this.XXX.this.AAA,很繁琐
2.在log.vue中调用log.hook.ts方法时,有时候会报this的错误
需求,有什么更好的拆分方法吗?
1.为了抽离逻辑内容,避免一个文件代码太多
2.逻辑代码使用class,可以抽离通用逻辑和工具到common,其他文件可以继承使用