Nav apraksta

README.md 1.5KB

babel-preset-vue

Babel preset for all Vue plugins.

Install

npm install -D babel-preset-vue

CDN: UNPKG

Usage

{
  "presets": ["vue"]
}

Supports event modifiers.

Uses babel-plugin-jsx-event-modifier for event modifiers.

Example:

Vue.component('hello-world', {
  methods: {
    method () {
      console.log('clicked')
    }
  },
  render () {
    return (
      <div>
        <a href="/" onClick:prevent={this.method} />
      </div>
    )
  }
})

More information available on plugin's github page.

Supports functional components.

Uses babel-plugin-jsx-vue-functional for functional components.

Example:

const A = ({ props }) => <h1>{props.msg}</h1>
const B = ({ listeners }) => (
  <div onClick={listeners.click}>
    <A msg="Hello World!">
  </div>
)

More information available on plugin's github page.

Supports v-model.

Uses babel-plugin-jsx-v-model for two-way data binding with form elements.

Example:

Vue.component('hello-world', {
  data: () => ({
    text: 'Hello World!'
  }),
  render () {
    return (
      <div>
        <input type="text" v-model={this.text} />
        {this.text}
      </div>
    )
  }
})

More information available on plugin's github page.

License

MIT © EGOIST