babel-preset-vue
babel-preset-vue
Babel preset for all Vue plugins.
Install
npm install -D babel-preset-vue
CDN: UNPKG
Usage
In your .babelrc:
{
"presets": ["vue"]
}
You can toggle specific features, by default all features are enabled, e.g.:
{
"presets": [
["vue", {
"eventModifiers": false
}]
]
}
JSX Features
Note that following features are not available for babel v7 currently, you may disable them if necessary.
Event modifiers
Option name: eventModifiers
Uses babel-plugin-jsx-event-modifier for adding event modifiers support.
Example:
Vue.component('hello-world', {
methods: {
method () {
console.log('clicked')
}
},
render () {
return (
<div>
<a href="https://github.com/egoist/babel-preset-vue/blob/HEAD/" onClick:prevent={this.method} />
</div>
)
}
})
v-model
Options name: vModel
Uses babel-plugin-jsx-v-model for adding v-model support.
Example:
Vue.component('hello-world', {
data: () => ({
text: 'Hello World!'
}),
render () {
return (
<div>
<input type="text" v-model={this.text} />
{this.text}
</div>
)
}
})
License
MIT © EGOIST
Related Packages
babel-preset-typescript-vue3
TypeScript preset for Babel 7.x supporting Vue.js 3 components written in TS
239,533
6
Version History
| Version | Released | License |
|---|---|---|
| 2.0.2 | MIT | |
| 2.0.1 | MIT | |
| 2.0.0 | MIT | |
| 1.2.1 | MIT | |
| 1.2.0 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT | |
| 0.2.0 | MIT | |
| 0.1.0 | MIT |