useLoremIpsum

一个 React Hook,用于生成 Lorem Ipsum 文本。适用于测试和占位文本。

演示

源码
[Stable] Cillum do id, laboris ut ut.
[Unstable] Consequat fugiat quis qui ea exercitation pariatur consectetur occaecat, ut qui!
[Length: 2] Ad consectetur eu proident veniam irure eu fugiat cupidatat. Adipiscing fugiat dolore incididunt veniam tempor!

用法

请查看 API。

源码

点击下方链接跳转 GitHub 查看源代码。

API

const text = useLoremIpsum(length) // 默认为 1 句
const text = useLoremIpsum(options)

句子长度 Length

一个 number 类型的值,代表要生成的句子数量。

选项 Options

export interface UseLoremIpsumOptions {
  /**
   * 生成的文本句子的长度。
   *
   * @defaultValue 1
   */
  length?: number
  /**
   * 一个句子中的最小词语数量。
   *
   * @defaultValue ['.', '!', '?']
   */
  sentenceEnds?: string[]
  /**
   * 是否在渲染间保持同一个值。
   *
   * @defaultValue true
   */
  stable?: boolean
}

返回值

代表生成文本的一个 string 类型的值。