randomColor
Definition:
js
/**
* @returns Randomly generated color value
* @param type - Type of color to generate, 'hex' or 'rgb'
* @param opacity - Opacity value
* @description Generate a random hexadecimal color value or rgba color
*/
Demo
type:
opacity:
generated random color -> #99a34f
Usage Example
ts
import { computed, ref } from 'vue'
import { randomColor } from 'utils-snap-fn'
const hexColor = computed(() => {
return randomColor('hex')
})
const rgbColor = computed(() => {
return randomColor('rgb', 0.8)
})