Skip to content

Configuration ​

Set options ​

Pass options when installing:

ts
app.use(VuEPG, { focusClass: "focused", debug: import.meta.env.DEV });

Or call setConfig at any time with the fields you want to change:

ts
useVuEPG().setConfig({ debug: true });

getConfig() reads the current readonly configuration.

Configuration options ​

ts
/** 返回处理函数 */
export type BackHandler = () => void;

/** 全局配置 */
export interface EPGConfig {
  /**
   * 焦点元素的 class 名,可被 `v-epg-item` 的 `focusClass` 覆盖
   * @defaultValue `"vuepg-focus"`
   */
  focusClass: string;
  /**
   * 全局返回处理函数:按下返回键且没有生效中的 `onBack` 时调用
   * @defaultValue `null`
   */
  backHandler: BackHandler | null;
  /**
   * 是否在控制台输出调试日志
   * @defaultValue `false`
   */
  debug: boolean;
  /**
   * 文档视口的滚动方式;`true` 等同于 `"nearest"`,`false` 关闭
   * @defaultValue `false`
   */
  scrollViewport: boolean | ScrollMode;
}

focusClass ​

The selected element receives this class. Changing it immediately replaces the current class. Individual items can override it with focusClass.

A class must be a nonempty string without whitespace; otherwise setConfig throws TypeError.

backHandler ​

Fallback invoked on Back when no active component handler exists. See Back handling.

debug ​

Logs movement, keys, registration and unregistration. Direction lookup also logs candidates and results at each level to explain target selection.

scrollViewport ​

Document viewport scrolling, disabled by default. true means "nearest"; "start" and "center" are also available. Independent from element v-epg-scroll; see Scrolling.