@kdujs/babel-sugar-k-on
v1.4.0
Published
Babel syntactic sugar for k-model support in Kdu JSX
Downloads
47
Readme
@kdujs/babel-sugar-k-on
Syntactic sugar for k-on in JSX.
Usage
Install the dependencies:
# for yarn:
yarn add @kdujs/babel-sugar-k-on
# for npm:
npm install @kdujs/babel-sugar-k-on --save
In your .babelrc
:
{
"plugins": ["@kdujs/babel-sugar-k-on"]
}
However it is recommended to use the configurable preset instead.
Details
This plugin adds k-on to the JSX and tries to mirror the same behaviour as in kdu-template-compiler, with a few differences:
- You should use underscore (
_
) instead of dot (.
) for modifiers (kOn:click_prevent={this.test}
) - It is recommended to use camelCase version of it (
kOn
) in JSX, but you can use kebab-case too (k-on
).
export default {
methods: {
test() {
console.log('Hello World')
},
},
render(h) {
return (
<div>
<a href="https://kdu-js.web.app" kOn:click={this.test}>Kdu</a>
</div>
)
},
}