hooks,模块编程

在目录下创建一个hooks文件夹,里面存放各种useXxx.ts

各种模块需要暴露模块自身需要暴露的数据和方法

import {ref} from 'vue'

export default function () {
    let count = ref(0);
    function add() {
        count.value++;
    }
    return {count,add}
}
//在需要引入的地方引入
<script setup lang="ts">
    import useSum from '@/hooks/useSum'
    const { count, add } = useSum()
</script>