vue组件之间循环调用 报错-——(递归组件)

395 阅读1分钟

vue组件之间循环调用 [Vue warn]: Unknown custom element: <组件名> - did you register the component correctly? For recursive components, make sure to provide the "name" option 解决办法 一:生命周期钩子 beforeCreate 时去注册它

beforeCreate: function () {
  this.$options.components.TreeFolderContents = require('./tree-folder-contents.vue').default
}

二:在本地注册组件的时候,你可以使用 webpack 的异步 import

components: {
  TreeFolderContents: () => import('./tree-folder-contents.vue')
}