封装组合式函数

封装组件
import type { XtxGuessInstance } from '@/types/components'
import { ref } from 'vue'

/**

  • 猜你喜欢组合式函数
    */
    export const useGuessList = () => {
    // 获取猜你喜欢组件实例
    const guessRef = ref()

// 滚动触底事件
const onScrolltolower = () => {
guessRef.value?.getMore()
}

// 返回 ref 和事件处理函数
return {
guessRef,
onScrolltolower,
}
}

页面使用

const { guessRef, onScrolltolower } = useGuessList()

posted @ 2024-03-27 15:58  小白张先生  阅读(16)  评论(0)    收藏  举报