小编Leo*_*ler的帖子

NuxtLink 的子级渲染两次(水合错误?)

跨度渲染两次

我的预感是存在一些水合不匹配,其中FontAwesomeIcon未在服务器上渲染(仅span),然后在客户端上NuxtLink渲染 的两个子节点(svgspan),提示 Nuxt 渲染span两次。

但控制台不会返回错误。

关于如何调试这个有什么想法吗?

这是 Vue 组件:

<template>
  <ul v-if="routes.length > 0" class="col-span-2 flex flex-col">
    <li v-for="(item, i) in routes" :key="item.name">
      <NuxtLink :to="item.path" target="_blank">
        <FontAwesomeIcon :icon="item.icon" class="mr-3" fixed-width />
        <span>{{ item.title }}</span>
      </NuxtLink>
    </li>
  </ul>
</template>

<script lang="ts">
export default defineComponent({
  props: {
    links: {
      type: Array,
      default: () => ["instagram", "facebook", "email"],
    },
  },
  computed: {
    routes() {
      return [
        {
          name: "instagram",
          path: "https://www.instagram.com/insta.name/", …
Run Code Online (Sandbox Code Playgroud)

mismatch vue.js server-side-rendering hydration nuxt.js

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

更新依赖项后,什么可能会导致 Nuxt.js 应用程序出现 500 错误,而控制台中没有任何错误消息?

我最近更新了 Nuxt 应用程序中的一些依赖项,现在我无法启动该应用程序。当我尝试访问 localhost:3000 处的应用程序时,收到 500 错误。但是,当我检查终端中的服务器控制台时,我没有看到抛出任何错误。

我在浏览器控制台中看到的错误消息是:

500
[vite-node] [plugin:vite:import-analysis] [VITE_ERROR] /@fs./node_modules/nuxt/dist/app/entry.mjs

import { createSSRApp, createApp, nextTick } from "vue";
import { $fetch } from "ofetch";
import { baseURL } from "#build/paths.mjs";
import { createNuxtApp, applyPlugins, normalizePlugins } from "#app";
import "#build/css";
import _plugins from "#build/plugins";
import RootComponent from "#build/root-component.mjs";
import { appRootId } from "#build/nuxt.config.mjs";
if (!globalThis.$fetch) {
  globalThis.$fetch = $fetch.create({
    baseURL: baseURL()
  });
}
let entry;
const plugins = normalizePlugins(_plugins);
if (true) {
  entry = async function …
Run Code Online (Sandbox Code Playgroud)

node.js npm nuxt.js

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