配置变量 | 信息 |
|---|
htmx.config.historyEnabled | 默认为true,仅对测试有用 |
htmx.config.historyCacheSize | 默认为10 |
htmx.config.refreshOnHistoryMiss | 默认为false,如果设置为true,htmx将在历史未命中时完全刷新页面而不是使用AJAX请求 |
htmx.config.defaultSwapStyle | 默认为innerHTML |
htmx.config.defaultSwapDelay | 默认为0 |
htmx.config.defaultSettleDelay | 默认为20 |
htmx.config.includeIndicatorStyles | 默认为true(决定是否加载指示器样式) |
htmx.config.indicatorClass | 默认为htmx-indicator |
htmx.config.requestClass | 默认为htmx-request |
htmx.config.addedClass | 默认为htmx-added |
htmx.config.settlingClass | 默认为htmx-settling |
htmx.config.swappingClass | 默认为htmx-swapping |
htmx.config.allowEval | 默认为true,可用于禁用htmx对eval的使用(例如触发器过滤器) |
htmx.config.allowScriptTags | 默认为true,决定htmx是否处理新内容中的脚本标签 |
htmx.config.inlineScriptNonce | 默认为'',表示不会向内联脚本添加nonce |
htmx.config.inlineStyleNonce | 默认为'',表示不会向内联样式添加nonce |
htmx.config.attributesToSettle | 默认为["class", "style", "width", "height"],稳定阶段要稳定的属性 |
htmx.config.wsReconnectDelay | 默认为full-jitter |
htmx.config.wsBinaryType | 默认为blob,通过WebSocket连接接收的二进制数据类型 |
htmx.config.disableSelector | 默认为[hx-disable], [data-hx-disable],htmx不会处理具有此属性或其父元素具有此属性的元素 |
htmx.config.disableInheritance | 默认为false。如果设置为true,将完全禁用属性继承,此时可以使用hx-inherit属性手动控制继承。 |
htmx.config.withCredentials | 默认为false,允许跨域请求携带凭据(如cookies、授权头或TLS客户端证书) |
htmx.config.timeout | 默认为0,表示请求自动终止前的超时毫秒数 |
htmx.config.scrollBehavior | 默认为'instant',在使用show修饰符时的滚动行为。可选值有instant(立即跳转)、smooth(平滑滚动)和auto(由scroll-behavior的CSS计算值决定)。 |
htmx.config.defaultFocusScroll | 聚焦元素是否自动滚动到视图中,默认为false,可通过focus-scroll交换修饰符覆盖 |
htmx.config.getCacheBusterParam | 默认为false,若设为true,htmx会在GET请求后追加org.htmx.cache-buster=targetElementId格式的目标元素参数 |
htmx.config.globalViewTransitions | 若设为true,htmx将在内容交换时使用视图过渡API |
htmx.config.methodsThatUseUrlParams | 默认为["get", "delete"],这些方法的请求参数将被编码在URL中而非请求体 |
htmx.config.selfRequestsOnly | 默认为true,是否仅允许向当前文档同域的AJAX请求 |
htmx.config.ignoreTitle | 默认为false,若设为true,当发现新内容中有title标签时htmx不会更新文档标题 |
htmx.config.scrollIntoViewOnBoost | 默认为true,是否将增强元素的目标滚动到视图中。若增强元素未指定hx-target,则默认以body为目标,导致页面滚动到顶部。 |
htmx.config.triggerSpecsCache | 默认为null,用于存储已解析的触发器规范的缓存,可提升解析性能但会增加内存使用。可定义普通对象作为永久缓存,或使用代理对象实现自定义系统 |
htmx.config.responseHandling | 可在此配置不同状态码的默认响应处理行为(交换或报错) |
htmx.config.allowNestedOobSwaps | 默认为true,是否处理主响应元素内嵌套元素的OOB交换。参见嵌套OOB交换。 |
htmx.config.historyRestoreAsHxRequest | 默认为true,是否将历史缓存未命中的整页重载请求视为"HX-Request"(通过返回此响应头)。当使用HX-Request头选择性返回部分响应时,应始终禁用此选项 |