我正在尝试运行一个基本的 Nuxt 应用程序,其中包含使用 lerna monorepo 内的 vue-cli 构建的外部 Vue 组件。
\n\n该页面简要显示组件内容(服务器呈现),然后消失并抛出以下错误。
\n\n"export \'default\' (imported as \'Header\') was not found in \'a2b-header\'
其次是
\n\nMismatching childNodes vs. VNodes: NodeList(7)\xc2\xa0[svg, text, div#app, text, h2.subtitle, text, div.links] (7)\xc2\xa0[VNode, VNode, VNode, VNode, VNode, VNode, VNode]
最后是红色的 Vue 警告
\n\n[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. …
我正在用 TypeScript 编写 Nuxt 应用程序。我在尝试访问 Nuxt 上的 $i18n 对象时遇到了问题。我在 VS Code 中收到一条警告:
Property '$i18n' does not exist on type 'MyClass'.
Run Code Online (Sandbox Code Playgroud)
我的组件代码中的脚本部分如下所示:
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
import ILocale from '~/types/vue/Locales'
@Component
export default class MyClass extends Vue {
@Prop({ type: Boolean, default: true }) showLanguageSwitch!: boolean
get availableLocales(): ILocale[] {
return this.$i18n.locales.filter((l) => l.code !== this.$i18n.locale)
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我在项目的根目录中有一个填充文件:
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
Run Code Online (Sandbox Code Playgroud)
这是我应该扩展接口的地方吗?我实际上如何做到这一点,因为Vue它不是 …