useLoremIpsum

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

演示

源码
[Stable] Exercitation culpa anim magna tempor ea cillum excepteur!
[Unstable] Consectetur veniam quis reprehenderit sed veniam.
[Length: 2] Nostrud laboris labore, anim eiusmod proident magna nisi. Fugiat ipsum magna eu laborum cillum deserunt eiusmod minim non excepteur?

用法

请查看 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 类型的值。