| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { createApp } from 'vue'
- import App from './App.vue'
- import router from './router'
- import Vant from 'vant'
- import 'vant/lib/index.css'
- import './assets/main.css'
- import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
- let instance = null
- function render(props = {}) {
- const { container } = props
- instance = createApp(App)
- instance.provide('microProps', props)
- instance.use(router)
- instance.use(Vant) // 移动端 UI 组件库 Vant
- instance.mount(container ? container.querySelector('#app') : document.getElementById('app'))
- }
- renderWithQiankun({
- bootstrap() {
- console.log('[mobile-app] bootstrap')
- },
- mount(props) {
- console.log('[mobile-app] mount', props)
- render(props)
- },
- update(props) {
- console.log('[mobile-app] update', props)
- },
- unmount() {
- console.log('[mobile-app] unmount')
- instance?.unmount()
- instance = null
- },
- })
- // 独立运行时直接渲染
- if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
- render()
- }
|