Huggingface.js 文档
🤗 Hugging Face Space Header
加入 Hugging Face 社区
并获得增强的文档体验
开始使用
🤗 Hugging Face Space Header
一个由 Typescript 驱动的 Space mini_header 功能封装。
![]()
安装
pnpm add @huggingface/space-header npm add @huggingface/space-header yarn add @huggingface/space-header
Deno
// esm.sh
import { init } from "https://esm.sh/@huggingface/space-header"
// or npm:
import { init } from "npm:@huggingface/space-header"初始化
import { init } from "@huggingface/space-header";
// ...
init(":user/:spaceId");
// init("enzostvs/lora-studio") for example❗重要提示:init 方法必须在客户端调用。
用法
使用 target 选项将 space-header 注入到另一个 DOM 元素中
const app = document.getElementById("app");
// ...
init(":user/:spaceId", {
target: app
});如果您已经有空间数据,也可以将其作为参数传递,以避免一次获取
init(space);
// space = {
// id: string;
// likes: number;
// author: string;
// }