@vue/babel-sugar-v-model
Babel syntactic sugar for v-model support in Vue JSX
36,604,110
1,474
| Install | |
|---|---|
npm install @vue/babel-sugar-v-model |
|
| Latest Version: | 1.4.0 |
| Vue: | 2 |
| License: | MIT |
| Last Updated: | May 31, 2024 |
| Links: | GitHub · npm |
Maintainer: nickmessing
@vue/babel-sugar-v-model
Syntactic sugar for v-model in JSX.
Babel Compatibility Notes
- This repo is only compatible with Babel 7.x, for 6.x please use vuejs/babel-plugin-transform-vue-jsx
Usage
Install the dependencies:
# for yarn:
yarn add @vue/babel-sugar-v-model
# for npm:
npm install @vue/babel-sugar-v-model --save
In your .babelrc:
{
"plugins": ["@vue/babel-sugar-v-model"]
}
However it is recommended to use the configurable preset instead.
Details
This plugin adds v-model to the JSX and tries to mirror the same behaviour as in vue-template-compiler, with a few differences:
- You should use underscore (
_) instead of dot (.) for modifiers (vModel_trim={this.test}) - It is recommended to use camelCase version of it (
vModel) in JSX, but you can use kebab-case too (v-model).
export default {
data: () => ({
test: 'Hello World',
}),
render(h) {
return (
<div>
<input type="text" vModel_trim={this.test} />
{this.test}
</div>
)
},
}
Related Packages
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 | |
| 1.1.2 | ^2.5.17 | MIT | |
| 1.1.1 | ^2.5.17 | MIT | |
| 1.0.0 | ^2.5.17 | MIT | |
| 0.1.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 |