小编irw*_*win的帖子

[Vue warn]:客户端渲染的虚拟 DOM 树与服务器渲染的内容不匹配(Nuxt / Vue / lerna monorepo)

我正在尝试运行一个基本的 Nuxt 应用程序,其中包含使用 lerna monorepo 内的 vue-cli 构建的外部 Vue 组件。

\n\n

该页面简要显示组件内容(服务器呈现),然后消失并抛出以下错误。

\n\n

"export \'default\' (imported as \'Header\') was not found in \'a2b-header\'

\n\n

其次是

\n\n

Mismatching 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]

\n\n

最后是红色的 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>. …

webpack vue.js lerna nuxt.js vue-cli

3
推荐指数
1
解决办法
2万
查看次数

Nuxt 应用程序中“类型 X 上不存在属性‘$i18n’”

我正在用 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它不是 …

typescript vue.js nuxt.js vue-i18n

1
推荐指数
1
解决办法
3398
查看次数

标签 统计

nuxt.js ×2

vue.js ×2

lerna ×1

typescript ×1

vue-cli ×1

vue-i18n ×1

webpack ×1