useLoremIpsum

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

演示

源码
[Stable] Anim quis minim, ad laborum adipiscing fugiat consequat ea qui ex.
[Unstable] Culpa id sed ex proident sed enim ad eu!
[Length: 2] Non sint reprehenderit, enim magna commodo mollit et ullamco. Culpa incididunt adipiscing nulla incididunt et adipiscing ullamco sit incididunt aliqua!

用法

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