使用说明
这是最短的页面接入方式。顶层 mount() 使用模块内置的默认 Runtime;需要明确 Runtime 所有权、共享资源或多实例隔离时,使用 runtime.mount(target, artifact, options)。
import { mount } from '@flamo/runtime';
const instance = await mount('#preview', artifact);mount(target, artifact, options) 会创建一个新 Instance,并在创建时绑定目标。它不是对已有 Instance 的二次挂载;FlamoInstance 没有 mount(target) 方法。
目标要求
- selector 字符串在浏览器中通过
document.querySelector()解析,找不到时抛出flamo.mount: target not found; HTMLCanvasElement会直接作为渲染表面;- 其他
Element会收到 Runtime 创建的子<canvas>,容器应能接收子节点并具有可见尺寸; Document、Window、ShadowRoot、null不属于公开目标类型。
不要与以下接口混淆:Card.mount() 是 Component API 使用默认 Runtime 的便捷方法;instance.mountChild()、mountComposition()、mountSlot() 修改当前 Instance 内部的 child/composition/slot,不会重设顶层 DOM 目标。