Skip to content

useSetTimeout

定时器

基础用法

<template>
  <g-button type="primary" @click="handle" :loading="loading">1s后执行</g-button>
</template>

<script setup lang="ts">
import { ElMessage } from 'element-plus';
import { GButton, useSetTimeout } from 'gao-components-plus'
import { ref } from 'vue';
const loading = ref(false)

function handle() {
  loading.value = true
  const { clear } = useSetTimeout(() => {
    loading.value = false
    ElMessage.success('执行了')
  }, 1000)
}

</script>

<style lang="scss" scoped>

</style>

参数

名称描述类型默认值
callback回调函数Function-
dalay延迟时间number-

返回参数

名称描述类型默认值
clear关闭定时器Function-

Released under the MIT License.