LiveVue.Components module provides macros that generate functions local to your module for rendering Vue components. This improves the developer experience by allowing you to call Vue components as Elixir functions.
Usage
Use this module with thevue_root option to specify directories containing your Vue components:
Path or list of paths to directories containing Vue components. The macro will scan for
*.vue files in these directories (including subdirectories) and generate corresponding functions.Default: ["./assets/vue"]Generated functions
For each*.vue file found in the specified directories, the macro generates a function with the same name as the component file (without the .vue extension).
The component assigns map containing attributes and props to pass to the Vue component.
Returns the rendered Vue component via
LiveVue.vue/1.Example
Given the following Vue components in./assets/vue:
Counter/1UserProfile/1Button/1
LiveVue.vue/1 with the appropriate v-component attribute set.
Implementation details
The macro:- Scans all
*.vuefiles in the specifiedvue_rootdirectories - Extracts the base filename (without extension) for each component
- Generates a function with that name that sets the
v-componentattribute and callsLiveVue.vue/1