使用Vite+vue3做练手项目进行学习,有时候为了方便,直接使用html原生组件进行测试,比如h1,button之类的。
但使用h1、button标签,会提示组件未定义的警告,但调试运行没有问题。
警告内容
Failed to resolve component: H1
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
at <Test
onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > >
at <RouterView>
at <App>
打包部署署运行的时候,没有提示该警告
你全局搜一下
H1
,记得要区分大小写。估计是你用了大写的H1
,虽然html不区分大小写,但是编译的时候报错了。补充:我在我的
vite+vue3
项目里试了下<H1>哈哈哈</H1>
但是并没有报错,你用的也是模板的写法吧