Skip to content

Instantly share code, notes, and snippets.

@Volmarg
Created March 29, 2021 16:00
Show Gist options
  • Save Volmarg/aad69945a95937cacca9ac0b6412c824 to your computer and use it in GitHub Desktop.
Save Volmarg/aad69945a95937cacca9ac0b6412c824 to your computer and use it in GitHub Desktop.
PreconfiguredVue
export default class PreconfiguredVue
{
/**
* @description delimiters used to translate vue logic, required since twig utilizes the `{{ }}`
*/
static readonly VUE_DEFAULT_DELIMITERS = ["[[", "]]"];
/**
* @description creates vue instance for dom element but uses preconfigured vue with common reusable logic,
* this provides the same output as creating SPA with vue in root such as body
*
* @param domElementSelector
* @param options
*/
public static createApp(domElementSelector: string, options)
{
//@ts-ignore
options.delimiters = PreconfiguredVue.VUE_DEFAULT_DELIMITERS;
let vueApp = vue.createApp(options);
vueApp.mount(domElementSelector);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment