@vue/babel-sugar-v-on

Babel syntactic sugar for v-model support in Vue JSX
36,598,920 1,474
Install
npm install @vue/babel-sugar-v-on
Latest Version:1.4.0
Vue:2
License:MIT
Last Updated:May 31, 2024
Links: GitHub  ·  npm
Maintainer: nickmessing

@vue/babel-sugar-v-on

Syntactic sugar for v-on in JSX.

Babel Compatibility Notes

Usage

Install the dependencies:

# for yarn:
yarn add @vue/babel-sugar-v-on
# for npm:
npm install @vue/babel-sugar-v-on --save

In your .babelrc:

{
  "plugins": ["@vue/babel-sugar-v-on"]
}

However it is recommended to use the configurable preset instead.

Details

This plugin adds v-on to the JSX and tries to mirror the same behaviour as in vue-template-compiler, with a few differences:

  1. You should use underscore (_) instead of dot (.) for modifiers (vOn:click_prevent={this.test})
  2. It is recommended to use camelCase version of it (vOn) in JSX, but you can use kebab-case too (v-on).
export default {
  methods: {
    test() {
      console.log('Hello World')
    },
  },
  render(h) {
    return (
      <div>
        <a href="https://vuejs.org" vOn:click={this.test}>Vue</a>
      </div>
    )
  },
}

Related Packages

@vue/devtools-api

Plugins API for easier DevTools integrations.

471,046,026 2,932
@vue/compiler-vue2

template compiler for Vue 2.x

184,385,144 212,629
@vue/test-utils

Component testing utils for Vue 3.

171,749,877 1,161
@vue/babel-plugin-jsx

Babel plugin for Vue 3 JSX

153,148,630 1,781
@vue/eslint-config-typescript

ESLint config for TypeScript + Vue.js projects

76,955,056 192

Version History

Version Released Vue License
1.4.0 ^2.5.17 MIT
1.3.0 ^2.5.17 MIT
1.2.3 ^2.5.17 MIT
1.2.1 ^2.5.17 MIT
1.2.0 ^2.5.17 MIT
Pre-releases (3)
Version Released Vue License
1.0.0-beta.3 ^2.5.17 MIT
1.0.0-beta.2 ^2.5.17 MIT
1.0.0-beta.1 ^2.5.17 MIT