index.html
添加id为all-component-box的容器,用于渲染自定义组件
<body>
<div id="app"></div>
<div id="all-component-box"></div>
<script type="module" src="/src/main.ts"></script>
</body>
在App.vue
<template></template>
<script setup lang="ts">
import { createApp, h } from 'vue'
import { onLaunch } from '@dcloudio/uni-app'
import customComponent from '@/components/自定义组件.vue'
onLaunch(() => {
const ele = document.querySelector('#all-component-box') || ''
const app = createApp(h(customComponent, {}))
app.mount(ele)
})
</script>