Syntactic sugar for v-bind sync
modifier in JSX.
This repo is only compatible with Babel 7.x, for 6.x please use njleonzhang/babel-plugin-vue-jsx-sync
Install the dependencies:
# for yarn:
yarn add -D babel-sugar-v-bind-sync
# for npm:
npm install babel-sugar-v-bind-sync --save-dev
In your .babelrc
:
module.exports = {
plugins: [require('babel-sugar-v-bind-sync')]
}
This plugin adds v-bind sync
modifier to the JSX and tries to mirror the same behavior as in vue-template-compiler, with a few differences:
- You should use underscore (
_
) instead of dot (.
) forsync
modifier (prop_sync={this.bar}
). - It is recommended to use camelCase version of it (
propName_sync
) in JSX, but you can use kebab-case too (prop-name_sync
).
export default {
data() {
return {
bar: 'naz',
};
},
render(h) {
return (
<div>
<component foo_sync={this.bar} />
</div>
);
},
};