Skip to content

Commit 7f0d718

Browse files
committed
docs: Add info about vOn to README
1 parent 8e7d8f2 commit 7f0d718

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

packages/babel-preset-jsx/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ Options are:
4545
- `functional` [@vue/babel-sugar-functional-vue](../babel-sugar-functional-vue/README.md) - Functional components syntactic sugar
4646
- `injectH` [@vue/babel-sugar-inject-h](../babel-sugar-inject-h/README.md) - Automatic `h` injection syntactic sugar
4747
- `vModel` [@vue/babel-sugar-v-model](../babel-sugar-v-model/README.md) - `vModel` syntactic sugar
48+
- `vOn` [@vue/babel-sugar-v-on](../babel-sugar-v-on/README.md) - `vOn` syntactic sugar

packages/babel-sugar-v-on/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## @vue/babel-sugar-v-on
2+
3+
Syntactic sugar for v-on in JSX.
4+
5+
### Babel Compatibility Notes
6+
7+
- This repo is only compatible with Babel 7.x, for 6.x please use [vuejs/babel-plugin-transform-vue-jsx](https://github.com/vuejs/babel-plugin-transform-vue-jsx)
8+
9+
### Usage
10+
11+
Install the dependencies:
12+
13+
```sh
14+
# for yarn:
15+
yarn add @vue/babel-sugar-v-on
16+
# for npm:
17+
npm install @vue/babel-sugar-v-on --save
18+
```
19+
20+
In your `.babelrc`:
21+
22+
```json
23+
{
24+
"plugins": ["@vue/babel-sugar-v-on"]
25+
}
26+
```
27+
28+
However it is recommended to use the [configurable preset](../babel-preset-jsx/README.md) instead.
29+
30+
### Details
31+
32+
This plugin adds v-on to the JSX and tries to mirror the same behaviour as in vue-template-compiler, with a few differences:
33+
34+
1. You should use underscore (`_`) instead of dot (`.`) for modifiers (`vOn:click_prevent={this.test}`)
35+
2. It is recommended to use camelCase version of it (`vOn`) in JSX, but you can use kebab-case too (`v-on`).
36+
37+
```js
38+
export default {
39+
methods: {
40+
test() {
41+
console.log('Hello World')
42+
},
43+
},
44+
render(h) {
45+
return (
46+
<div>
47+
<a href="https://vuejs.org" vOn:click={this.test}>Vue</a>
48+
</div>
49+
)
50+
},
51+
}
52+
```

0 commit comments

Comments
 (0)