Custom Functions
Last updated
Last updated
Custom functions are written like any normal JavaScript function. A components reactive store can be accessed via the or . We recommend the use of custom functions wherever possible to minimise complex logic creeping into attributes.
Whilst this is convenient, it becomes significantly more challenging to maintain.
In this example, we utilise the magic references available in attribute expressions.
$store
Reference to the components reactive store
✅
$el
Reference to the DOM element bound to the directive
✅
$event
Reference to the Event
emitted from the user action
✅
Here's the submitForm()
function used in the x-on:submit
example.