Skip to content

shortBind NPM Version

Stability: stable

A shorthand for binding prop with the same data name.

:value -> :value="value"

FeaturesSupported
Vue 3
Nuxt 3
Vue 2
Volar Plugin

Usage

Basic Usage

vue
<script setup>
const 
value
= 'foo'
</script> <template> <
input
:
value
/>
<!-- => <input :foo="value" /> --> </template>

With shortVmodel

vue
<template>
  <Comp ::value />
  <!-- => <Comp ::foo="foo" /> => <Comp v-model:foo="foo" /> -->
  <Comp $foo />
  <!-- => <Comp $foo="foo" /> => <Comp v-model:foo="foo" /> -->
  <Comp *foo />
  <!-- => <Comp *foo="foo" /> => <Comp v-model:foo="foo" /> -->
</template>

Volar Configuration

jsonc
// tsconfig.json
{
  "vueCompilerOptions": {
    "plugins": [
      "@vue-macros/volar/short-bind",
      // ...
    ],
  },
}

Contributors

The avatar of contributor named as Kevin Deng Kevin Deng

Changelog