@finsweet/attributes

中文文档
2.7.1发布于 2026/05/25Apache-2.0ES Module构建来源已验证近 30 天下载 2295

Finsweet 属性 V2

中文使用文档
文档目录6 节
  1. 什么是属性?
  2. 开始
  3. API 参考
  4. 这个 FinsweetAttributes 对象
  5. 这个 FinsweetAttributeControls 对象
  6. 这个 FinsweetAttributes.utils 对象
Attributes by Finsweet - Free powerful features for your site, no confusing code

npm Hits License

什么是属性?

属性是一个开源 JavaScript 库,包含用于添加过滤器,排序,加载和搜索选项,CMS分页和滑行器的解决方案,以及更多使用简单的HTML属性向Web流量.

开始

请注意这里的文件 fisweet.com/属性 互联网档案馆的存檔,存档日期2013-10-02 在 Webflow 项目中学习如何使用属性.

API 参考

属性将注入全局 window.FinsweetAttributes 对象输入包含一些与库互动的方法的项目.

在尝试访问库前确保库内装入 window.FinsweetAttributes 对象,可以使用下列即时代码:

window.FinsweetAttributes ||= [];
window.FinsweetAttributes.push([
  'ATTRIBUTE_KEY', // 'list', 'copyclip', 'modal', etc.
  (result) => {
    // Your code goes here.
  },
]);

结果对象将包含已装入属性解决方案的 API. 检查 README.md 每个属性解决方案的文档,以获取关于 API 的更多信息.

这个 FinsweetAttributes 对象

属性

财产类型说明
processSet包含当前活动属性解决方案.
modulesObject一个包含每个活动属性解决方案控件的密钥值对象。 每个键是相应的属性键,每个值是一个 Finsweet 属性控制 对象.
utilsObject包含与属性合作的功能.

方法

方法说明参数
push([key, callback])在属性装入后运行回调 .key (string): 属性密钥.
callback (function):召回函数.
load(key)动态加载属性解决方案 .key (string): 属性密钥.
destroy()破坏实例和所有属性解决方案.

这个 FinsweetAttributeControls 对象

属性

财产类型说明
versionstring属性的版本.
loadingPromise一旦属性装入并返回其 API , 就可以解决的承诺 .

方法

方法说明参数
restart()恢复属性 在实践中,这意味着属性会被再被销毁并装入.
destroy()摧毁属性.

这个 FinsweetAttributes.utils 对象

type FinsweetAttributesUtils = {
  /**
   * Fetches and parses an external page.
   * Stores the page response in an IndexedDB if the page belongs to the same site.
   *
   * @param source The URL of the page to fetch
   * @param options Optional configuration object
   * @returns Promise that resolves to the page's Document if successful, null otherwise
   */
  fetchPage: (
    source: string | URL,
    options?: {
      cache?: boolean; // Whether to cache fetched documents. Defaults to `true`
      cacheExternal?: boolean; // Whether to cache external documents using a stale-while-revalidate strategy
      cacheKey?: string; // Manual database name for the IndexedDB instance
      cacheVersion?: number; // Manual version for the IndexedDB instance
    }
  ) => Promise<Document | null> | null;

  /**
   * Attaches external stylesheets from a fetched page to the current document head.
   * Only attaches stylesheets hosted on the Webflow Assets CDN that aren't already present.
   *
   * @param page The Document object from which to extract stylesheets
   * @returns Promise that resolves when all stylesheets have been attached
   */
  attachExternalStylesheets: (page: Document) => Promise<void>;
};

版本与发布记录

@finsweet/attributes 共发布 87 个版本,首次发布于 2024/03/22;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.7.1latest2026/05/255 个月前
2.7.02026/05/255 个月前
2.6.332026/04/166 个月前
2.6.322026/04/166 个月前
2.6.312026/03/247 个月前
2.6.302026/03/177 个月前

关于 @finsweet/attributes 的常见问题

@finsweet/attributes 是什么?

Finsweet 属性 V2

如何安装 @finsweet/attributes?

在项目目录运行 npm install @finsweet/attributes,或使用 pnpm add / yarn add / bun add。

@finsweet/attributes 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/finsweet__attributes 是否存在。

@finsweet/attributes 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@finsweet/attributes 可以商用吗?

@finsweet/attributes 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@finsweet/attributes 的下载量有多少?

根据 npm 官方下载统计,@finsweet/attributes 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,295 次,日均约 77 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@finsweet/attributes 还在维护吗?

最新版本 2.7.1 发布于 2026/05/25(5 个月前);至今共发布 87 个版本,其中过去 12 个月发布了 16 个;首次发布于 2024/03/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。