Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
当我们组件涉及嵌套引用时,即父组件 A 引用了子组件 B,子组件 B 中又引用了组件 A。就会报上面错误。
解决方法有3种:
1,全局注册 A
Vue.components('A', A);
2,使用 beforeCreate
beforeCreate: function () {
this.$options.components.A = require('./A.vue').default
}
3,使用lambda 引用
components: {
A: () => import('./A.vue')
}
vite build 时,明明有 .env 文件,但是没生效,这是为什么?
有可能是 .env 文件的编码不正确,比如是 utf-16 而非 utf-8。
这种情况常见于自动化流程中使用 echo xxx >> .env 。