id: ecosystem-riot title: single-spa-riot

sidebar_label: Riot

single-spa-riot是一个帮助实现single-spa注册应用生命周期函数(引导、挂载和卸载)的工具库,可与riot一起使用。 仓库地址见single-spa-riot github

NPM

Build Status

minified

Installation

  1. npm install --save single-spa-riot

Usage

  1. import * as Riot from 'riot';
  2. import singleSpaRiot from 'single-spa-riot';
  3. import App from './App.riot'
  4. const riotLifecycles = singleSpaRiot({
  5. rootComponent: Riot.component(App),
  6. domElementGetter: () => document.getElementById('#app')
  7. });
  8. export const bootstrap = riotLifecycles.bootstrap;
  9. export const mount = riotLifecycles.mount;
  10. export const unmount = riotLifecycles.unmount;

Options

在调用singleSpaRiot(opts)方法时,opts 参数会将所有选项传递给single-spa-riot。选项如下:

  • domElementGetter: (必填) 回调函数,返回根组件挂载的元素。
  • rootComponent: (选填,将会替换 appOptions.loadRootComponent) riot根组件。
  • loadRootComponent: (选填,将会替换 appOptions.rootComponent) 一个返回根元素的Promise对象,它对于实现懒加载很有帮助。