Babel syntactic sugar for v-model support in Vue JSX
npm install @vue/babel-sugar-v-onSyntactic sugar for v-on in JSX.
- This repo is only compatible with Babel 7.x, for 6.x please use vuejs/babel-plugin-transform-vue-jsx
Install the dependencies:
``sh`for yarn:
yarn add @vue/babel-sugar-v-onfor npm:
npm install @vue/babel-sugar-v-on --save
In your .babelrc:
`json`
{
"plugins": ["@vue/babel-sugar-v-on"]
}
However it is recommended to use the configurable preset instead.
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})vOn
2. It is recommended to use camelCase version of it () in JSX, but you can use kebab-case too (v-on).
`js``
export default {
methods: {
test() {
console.log('Hello World')
},
},
render(h) {
return (
)
},
}