yarn create @vitejs/app vue-vite-example --template vue-ts
yarn
yarn add single-spa-vue single-spa
import { h, createApp, ComponentPublicInstance } from 'vue';
import singleSpaVue from 'single-spa-vue';
import { AppProps } from 'single-spa';
import App from './App.vue';
interface myAppProps {
myProp: string;
}
const vueLifecycles = singleSpaVue({
createApp,
appOptions: {
render() {
const that = this as ComponentPublicInstance<AppProps, myAppProps>;
return h(App, {
name: that.name,
mountParcel: that.mountParcel,
singleSpa: that.singleSpa,
myProp: that.myProp,
});
},
},
});
export const bootstrap = vueLifecycles.bootstrap;
export const mount = vueLifecycles.mount;
export const unmount = vueLifecycles.unmount;
defineComponent({
props: {
name: {
type: String,
default: 'default name',
},
mountParcel: {
type: Function as PropType<AppProps['mountParcel']>,
default: 'default name',
},
singleSpa: {
type: Object as PropType<AppProps['singleSpa']>,
default: 'default name',
},
myProp: {
type: String,
default: 'defaultV',
},
},
})
online example https://ff.intra.xiaojukeji.com/t#/vue-vite-example