1. @vue/babel-sugar-v-on
Babel syntactic sugar for v-model support in Vue JSX
@vue/babel-sugar-v-on
Package: @vue/babel-sugar-v-on
Created by: vuejs
Last modified: Thu, 25 Aug 2022 11:55:08 GMT
Version: 1.4.0
License: MIT
Downloads: 3,591,407
Repository: https://github.com/vuejs/jsx

Install

npm install @vue/babel-sugar-v-on
yarn add @vue/babel-sugar-v-on

@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 POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code