全局组件:
com.vue
<template>
<div>
我是com全局组件
</div>
</template>
<script setup lang='ts'>
import { ref } from 'vue'
</script>
main.ts
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import com from './components/com.vue'
const app = createApp(App)
app.component('Com',com) // 第一个参数是自定义组件名称,第二个参数是你当前的组件名称
app.use(createPinia())
app.use(router)
app.mount('#app')
局部组件:
box.vue
<template>
<div>
我是局部组件
</div>
</template>
<script setup lang='ts'>
import { ref } from 'vue'
</script>
<style scoped>
</style>
index.vue
<template>
<div&g