[Answered ]-Placing functions in vue.js that accept parameters and do not operate on variables in the component

1👍

This kind of helper function is known as a filter in Vue 2, and it could be used like:

{{ item | displayString }}

Filters were removed in Vue 3, now functions are supposed to be used directly in a template like:

{{ displayString(item) }}

This function is general-purpose formatter that is not specific to a store and doesn’t use its state, so it doesn’t belong to Pinia. Instead, displayString can be imported in a component where needed. Or be registered globally:

app.config.globalProperties.displayString = displayString

Leave a comment