useRandomString
Introduction
生成随机字符串
Basic Usage
ts
import { useRandomString } from '@flypeng/tool/browser';
const randomStr1 = useRandomString();
const randomStr2 = useRandomString(20);
const randomStr3 = useRandomString(20, true);
Online Demo
useRandomString
默认长度:EJUZPVCOMT
自定义长度:XGQMDJKXARQURXDWNEER
参杂数字:SMB1GXJBC8FRD1MQK7AN
<script lang="ts" setup>
import { useRandomString } from '@flypeng/tool/browser';
</script>
<template>
<div>
<div>
<span>默认长度:</span>
<span>{{ useRandomString() }}</span>
</div>
<div>
<span>自定义长度:</span>
<span>{{ useRandomString(20) }}</span>
</div>
<div>
<span>参杂数字:</span>
<span>{{ useRandomString(20, true) }}</span>
</div>
</div>
</template>
<style scoped></style>
Type Declaration
ts
/**
* 生成随机字符串
* @param length
* @param supportNumber 是否参杂数字(默认不参杂)
* @returns
*/
declare function useRandomString(length?: number, supportNumber?: boolean): string;