Skip to content

Directive Reference

This page provides a quick reference for all built-in directives available in pocket-vue.

DirectiveSyntaxDescription
v-scopev-scope="{ count: 0 }"Marks an element as a component and defines its scope.
v-ifv-if="ok", v-else-if, v-elseConditionally render elements.
v-showv-show="ok"Toggles visibility using CSS display.
v-forv-for="item in items"Iterate over arrays or objects.
v-modelv-model="msg"Two-way data binding on form inputs.
v-on@click="doThis", v-on:submit.preventAttach event listeners.
v-bind:src="imageSrc", v-bind:classReactive attribute binding.
v-effectv-effect="console.log(count)"Run reactive side effects.
v-textv-text="msg"Update element text content.
v-htmlv-html="rawHtml"Update element innerHTML.
v-cloakv-cloakHides uncompiled templates until ready.
v-prev-preSkip compilation for this element.
v-oncev-onceRender once and skip future updates.
refref="myDiv"Register a reference to an element.

Directives Summary

v-scope

Initializes reactive state for a DOM element and its children.

v-if

Toggle elements based on conditions. Elements are created/destroyed.

v-for

Repeat elements based on source data (arrays, objects, or ranges).

v-model

Create two-way data bindings for form inputs like text, checkbox, radio, and select.

v-on (@)

Handle browser events with optional modifiers like .prevent, .stop, and keyboard keys.

v-bind (: )

Dynamically update HTML attributes, classes, and styles.

v-show

Toggle visibility using the display CSS property without removing the element from the DOM.

v-effect

Perform complex side effects or integrate with 3rd-party libraries reactively.

Released under the MIT License.