WasmUX
← 返回文档列表

API 文档

常用导出速查

模块导出
核心WasmUXApp, compile, compileSmart, compileComponent, ref, reactive, computed, effect
HooksuseState, useEffect, useMemo, useCallback, useRef, useReducer, useContext, createContext
微前端registerMicroApps, start, initGlobalState, loadMicroApp, startMicroApp, stopMicroApp, preloadMicroApp, setMicroAppData, onMicroAppDataChange
Web ComponentregisterWasmuxMicroAppElement, WasmuxMicroAppElement, createMicroAppContainer
大数据sendBigData, receiveBigData, BigDataTransferManager
路由守卫beforeEach, afterEach, setSyncMode, hasPermission
性能runBenchmark, PerformanceTestSuite
调试DebugToolsManager, logInfo, logError, logWarn, logDebug

核心 API

WasmUXApp

javascript
const app = new WasmUXApp(container, {
  root: container,        // HTMLElement 根容器
  syntax: 'template',    // 'template' | 'jsx' | 'auto'
  data: () => ({ ... }),  // 可选:响应式数据,配合 {{ key }} 自动插值
  components?: {},        // 可选:组件注册
  enableMicro?: false,    // 可选:作为微应用子应用时启用
});

app.mount(templateOrVNode);  // 挂载
app.update(templateOrVNode); // 更新
app.unmount();               // 卸载
app.isMountedState();        // 是否已挂载

编译 API

javascript
compile(code, 'template' | 'jsx' | 'auto')  // 指定语法
compileSmart(code)                           // 自动识别语法
detectSyntaxType(code)                       // 返回 'template' | 'jsx'
compileBatch(codes)                           // 批量编译
compileComponent(source, options)             // 组件编译

响应式

javascript
ref(value)       // 基本类型
reactive(obj)    // 对象、数组
computed(fn)     // 计算属性
effect(fn)       // 副作用

导入方式

javascript
// 核心
import { WasmUXApp, compile, ref, reactive, useState, useEffect } from '@jianghuizhong/wasmux';

// 微前端(从子路径)
import { registerMicroApps, start, initGlobalState, loadMicroApp } from '@jianghuizhong/wasmux/micro';

// Web Component(从主包)
import { registerWasmuxMicroAppElement } from '@jianghuizhong/wasmux';