You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
侯晓宇
0cb2601919
|
4 weeks ago | |
---|---|---|
.. | ||
dist | 4 weeks ago | |
node_modules/html-tags | 4 weeks ago | |
README.md | 4 weeks ago | |
package.json | 4 weeks ago |
README.md
@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>
)
},
}