useCounter
具有实用功能的基本计数器。
基本用法
js
import { useCounter } from '@mpxjs/mpxuse-core'
const { count, inc, dec, set, reset } = useCounter()
import { useCounter } from '@mpxjs/mpxuse-core'
const { count, inc, dec, set, reset } = useCounter()
参数用法
js
import { useCounter } from '@mpxjs/mpxuse-core'
const { count, inc, dec, set, reset } = useCounter(1, { min: 0, max: 16 })
import { useCounter } from '@mpxjs/mpxuse-core'
const { count, inc, dec, set, reset } = useCounter(1, { min: 0, max: 16 })
类型声明
typescript
export interface UseCounterOptions {
min?: number
max?: number
}
/**
* Basic counter with utility functions.
*
* @see https://mpxuse.org/useCounter
* @param [initialValue=0]
* @param {Object} options
*/
export declare function useCounter(
initialValue?: number,
options?: UseCounterOptions
): {
count: Ref<number>
inc: any
dec: any
get: () => number
set: (val: number) => number
reset: any
}
export interface UseCounterOptions {
min?: number
max?: number
}
/**
* Basic counter with utility functions.
*
* @see https://mpxuse.org/useCounter
* @param [initialValue=0]
* @param {Object} options
*/
export declare function useCounter(
initialValue?: number,
options?: UseCounterOptions
): {
count: Ref<number>
inc: any
dec: any
get: () => number
set: (val: number) => number
reset: any
}