babel-preset-vue

Babel preset for all Vue plugins.

MIT 10 个版本
安装
npm install babel-preset-vue
yarn add babel-preset-vue
pnpm add babel-preset-vue
bun add babel-preset-vue
README

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="/" 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

版本列表
2.0.2 2018-03-21
2.0.1 2018-01-30
2.0.0 2017-12-06
1.2.1 2017-08-21
1.2.0 2017-08-18
1.0.2 2017-07-08
1.0.1 2017-07-08
1.0.0 2017-07-08
0.2.0 2017-04-07
0.1.0 2016-11-07