我新建了一个组件,hello.vue
<template>
<div>
123
</div>
</template
然后我在与 main.ts
的同级目录,新建了一个 index.ts
来写 install
方法
import hello from '@/components/hello.vue'
export const install = function (app: any) {
// 遍历注册全局组件
app.component('Hello', hello)
}
然后在使用时,会报如下的错误
是否要在注册全局组件时在声明文件中,写上组件的声明
需要写组件声明的,可以看下Volar的文档,文档