Core API
@makoojs/core 在浏览器中运行:创建 Core 实例、声明组件与监听、读取状态和处理错误。第一次使用请先完成快速开始。
导出索引
函数
| 导出 | 用途 | 参考 |
|---|---|---|
createMakoo() | 创建 Core 实例 | Core 实例 |
inject() | 声明组件 | 声明 |
injectEach() | 声明 Each 注入:在每个匹配元素上挂载同一个组件 | 声明 |
listen() | 声明宿主监听 | 声明 |
类与常量
| 导出 | 用途 | 参考 |
|---|---|---|
MakooError | Makoo 抛出或报告的错误 | 错误 |
MakooAggregateError | 汇总多个子错误 | 错误 |
MakooErrorCode | Core 错误码 | 错误 |
类型
| 类型 | 参考 |
|---|---|
MakooRuntime | Core 实例 |
ComponentInjection、ComponentEachInjection、ChildInjection、ListenerInjection | Core 实例 |
MakooComponentInput、MakooComponentDeclaration | 声明 |
MakooComponentEachInput、MakooComponentEachDeclaration | 声明 |
MakooListenerInput、MakooListenerDeclaration | 声明 |
MakooInjectionDeclaration | 声明 |
ComponentCommand、ChildCommand、ListenerCommand、InjectionCommand | 命令与状态 |
ComponentStatusHandle、ComponentEachStatusHandle、ChildStatusHandle、ListenerStatusHandle、InjectionStatusHandle | 命令与状态 |
ComponentStatus、ComponentEachStatus、ListenerStatus | 命令与状态 |
StateView | 命令与状态 |
ObservationNotice、ObservationHandler | 命令与状态 |
MountAdapter、AdapterMountParams | 适配器契约 |
最小示例
ts
import { createMakoo, inject } from '@makoojs/core';
import { createVueAdapter } from '@makoojs/vue';
import Panel from './Panel.vue';
const core = createMakoo();
core.useAdapter(createVueAdapter());
core.apply([
inject({ name: 'panel', injectAt: 'body', adapter: 'vue', component: Panel })
]);