babel-preset-kdu

1.2.1-alpha.0 • Public • Published

babel-preset-kdu

Babel preset for all Kdu plugins.

Install

npm install -D babel-preset-kdu

CDN: UNPKG

Usage

{
  "presets": ["kdu"]
}

Supports event modifiers.

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

Example:

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

Supports functional components.

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

Example:

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

Supports k-model.

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

Example:

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

License

MIT © 2021 NKDuy

Readme

Keywords

Package Sidebar

Install

npm i babel-preset-kdu

Weekly Downloads

2

Version

1.2.1-alpha.0

License

MIT

Unpacked Size

130 kB

Total Files

7

Last publish

Collaborators

  • nkduy