@kdujs/babel-sugar-k-model
v1.4.0
Published
Babel syntactic sugar for k-model support in Kdu JSX
Readme
@kdujs/babel-sugar-k-model
Syntactic sugar for k-model in JSX.
Usage
Install the dependencies:
# for yarn:
yarn add @kdujs/babel-sugar-k-model
# for npm:
npm install @kdujs/babel-sugar-k-model --saveIn your .babelrc:
{
"plugins": ["@kdujs/babel-sugar-k-model"]
}However it is recommended to use the configurable preset instead.
Details
This plugin adds k-model 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 (kModel_trim={this.test}) - It is recommended to use camelCase version of it (
kModel) in JSX, but you can use kebab-case too (k-model).
export default {
data: () => ({
test: 'Hello World',
}),
render(h) {
return (
<div>
<input type="text" kModel_trim={this.test} />
{this.test}
</div>
)
},
}