我正在尝试使用 quasar faramework 将我的自定义组件导入主布局文件中,但我不断地给出此消息“无法解析组件”,如果我将它们直接导入到加载到路线“/”上的索引文件中,它工作正常,没有任何问题,但是一旦我将它们导入到主布局中,错误就会存在,并且组件不会呈现。
`Failed to resolve component: logo
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
在
我尝试根据其他解决方案更改 quasar.congif.js,但它也不起作用 我将此部分添加到“构建”对象,如下所示:
chainWebpack(chain) {
chain.module
.rule("vue")
.use("vue-loader")
.tap((options) => {
options.compilerOptions = {
isCustomElement: (tag) => tag.startsWith("app-"),
};
return options;
});
},
还为我的自定义组件添加了“app-”前缀,但仍然收到消息
通常当你想在另一个页面导入组件时,你需要定义Component
import { defineComponent } from "vue";
export default defineComponent({
name: "NameOfVueComponent",
});
并在您希望导入或使用的页面中
import NameOfVueComponent from "src/components/NameOfVueComponent.vue";
export default {
components: { NameOfVueComponent },
setup(){
return{}
}
}
你需要在组件中定义它,然后你可以在你的页面中使用它
<NameOfVueComponent />