v0.6.22

Constructor Options

Last updated


This page lists every option accepted by new QUI(options), with its type, default, and how options interact.

Type


  1. new QUI(options: {
  2. id?: string;
  3. render?: () => string;
  4. data?: Record<string, any>;
  5. event?: Record<string, Function>;
  6. i18n?: Record<string, string | object>;
  7. i18nLang?: string;
  8. once?: boolean;
  9. option?: { svg?: boolean; lazyload?: boolean };
  10. when?: {
  11. beforeRender?: () => boolean | void;
  12. rendered?: (sec: number) => void;
  13. beforeUpdate?: () => boolean | void;
  14. updated?: (sec: number) => void;
  15. beforeDestroy?: () => boolean | void;
  16. destroyed?: (sec: number) => void;
  17. };
  18. })

Options


OptionTypeDefaultDescription
idstringNoneID of the element used as template and mount point
render() => stringNoneReturns a Render Shorthand string
dataobject{}Reactive data, see Reactive Data
eventobject{}Event handlers, see Event Binding
i18nobjectNoneLocale objects or JSON URLs, see i18n
i18nLangstring"zh"Initial locale
oncebooleanfalseWhen true, data is not wrapped in a Proxy and renders once
option.svgbooleantrueEnables SVG Inlining
option.lazyloadbooleantrueEnables Image Lazy Loading
whenobjectNoneLifecycle Hooks

Combining id and render


idrenderResult
SetNot setThe element's content is the template and the element is updated in place
SetSetThe output of render() replaces the element's content and becomes the template
Not setSetA detached <section class="QUIFragment"> is created; get the result with fragment()
Not setNot setAn error is logged and the instance does not render
Points to a missing elementAnyAn error is logged and the instance does not render

Interactions


CombinationResult
once: true + app.lang()The locale value changes but nothing re-renders
option.lazyload: false + :lazyload in the templateThrows
option.svg: false + <temp-svg :src> in the templateThrows
No whenHooks are read from a lifecycle object, then from the top level of the options (legacy forms, see Deprecations)
中文