Guide
Essentials
- Installation
- Introduction
- The Kdu Instance
- Template Syntax
- Computed Properties and Watchers
- Class and Style Bindings
- Conditional Rendering
- List Rendering
- Event Handling
- Form Input Bindings
- Components Basics
Components In-Depth
- Component Registration
- Props
- Custom Events
- Slots
- Dynamic & Async Components
- Handling Edge Cases
Transitions & Animation
- Enter/Leave & List Transitions
- State Transitions
Reusability & Composition
- Mixins
- Custom Directives
- Render Functions & JSX
- Plugins
- Filters
Tooling
- Single File Components
- TypeScript Support
- Production Deployment
Scaling Up
- Routing
- State Management
- Server-Side Rendering
- Security
Internals
- Reactivity in Depth
Migrating
- Migration to Kdu 2.7
Meta
- Meet the Team
Plugins
Plugins usually add global-level functionality to Kdu. There is no strictly defined scope for a plugin - there are typically several types of plugins:
Add some component options by global mixin. e.g.
kdu-router
Add some Kdu instance methods by attaching them to Kdu.prototype.
A library that provides an API of its own, while at the same time injecting some combination of the above. e.g.
kdu-router
Using a Plugin
Use plugins by calling the Kdu.use()
global method. This has to be done before you start your app by calling new Kdu()
:
|
You can optionally pass in some options:
|
Kdu.use
automatically prevents you from using the same plugin more than once, so calling it multiple times on the same plugin will install the plugin only once.
Some plugins provided by Kdu.js official plugins such as kdu-router
automatically calls Kdu.use()
if Kdu
is available as a global variable. However in a module environment such as CommonJS, you always need to call Kdu.use()
explicitly:
|
Writing a Plugin
A Kdu.js plugin should expose an install
method. The method will be called with the Kdu
constructor as the first argument, along with possible options:
|