【问题标题】:Nuxt error : nodeOps.tagName(...) is undefined in Vue framework's 'createPatchFunction'Nuxt 错误:nodeOps.tagName(...) 在 Vue 框架的“createPatchFunction”中未定义
【发布时间】:2021-08-25 06:34:07
【问题描述】:

在我的 nuxt 应用程序中,使用 this.$router.push({ path: '/path' }) 更改路线后,我在 firefox 中得到了 nodeOps.tagName(...) is undefined,在 chrome 中,我在同一行中得到了 cannot get access to .toLowerCase() of undefined

它发生在createPatchFunctionvue.runtime.esm.js 版本中:nuxt:^2.14.12, vue:^2.6.12

function createPatchFunction (backend) {
  // ...
  // some more vue framework code here
  // ...
  function emptyNodeAt (elm) {
    // the following line throws error and app crashes
    return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  }
}

更新:elm 参数属于 html 注释类型。

UPDATE-2: package.jsonnuxt.config.js 文件:

{
  "name": "name",
  "version": "1.0.0",
  "scripts": {
    "build": "nuxt build",
    "test": "jest",
    "dev": "nuxt",
    "generate": "nuxt generate",
    "start": "nuxt start"
  },
  "dependencies": {
    "@chenfengyuan/vue-number-input": "^1.2.1",
    "@nuxt/content": "^1.5.0",
    "@nuxtjs/axios": "^5.12.4",
    "@nuxtjs/gtm": "^2.4.0",
    "@nuxtjs/proxy": "^2.1.0",
    "nuxt": "^2.14.12",
    "vue": "^2.6.12",
    "vue-multiselect": "^2.1.6",
    "vue-numeric-input": "^1.0.6",
    "vuex-pathify": "^1.4.4"
  },
  "devDependencies": {
    "@babel/core": "7.12.17",
    "@babel/preset-env": "7.12.17",
    "@nuxtjs/style-resources": "^1.0.0",
    "@nuxtjs/svg": "^0.1.12",
    "@nuxtjs/vuetify": "^1.11.2",
    "@vue/cli-plugin-unit-jest": "^4.5.13",
    "@vue/test-utils": "^1.2.2",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "^27.0.6",
    "eslint": "^7.25.0",
    "eslint-plugin-vue": "^7.9.0",
    "jest": "^27.0.6",
    "vue-jest": "^3.0.7",
    "vue-svg-loader": "^0.16.0",
    "vue-template-compiler": "^2.6.12"
  }
}

nuxt.config.js

import colors from "vuetify/es5/util/colors";

export default {
  mode: "universal",
  target: "static",
  css: ["@/assets/scss/global.scss"],
  plugins: [
    "~/plugins/api/index.js",
    "~/plugins/sassVaribles/index.js",
    "~/plugins/datePicker/index.client.js",
    "~/plugins/globalComponents.js",
  ],
  components: false,
  buildModules: ["@nuxtjs/vuetify", "@nuxtjs/style-resources"],
  modules: [
    "@nuxtjs/axios",
    "@nuxt/content",
    "@nuxtjs/svg",
    "@nuxtjs/proxy"
  ],
  styleResources: {
    scss: ["@/assets/scss/main.scss"]
  },
  env: {
  },
  server: {
    port: 8089,
    host: "0.0.0.0"
  },
  axios: {
    baseURL: ""
  },
  vuetify: {
    customVariables: ["~/assets/variables.scss"],
    rtl: false,
    theme: {
      dark: false,
      default: "light",
      disable: false,
      options: {
        customProperties: true,
        variations: true
      },
      themes: {
        light: {
          primary: "#5050a0",
          accent: colors.grey.darken3,
          secondary: colors.amber.darken3,
          info: "#dddcec",
          warning: colors.amber.base,
          error: colors.deepOrange.accent4,
          success: colors.green.accent3
        },
        dark: {
          primary: colors.blue.darken2,
          accent: colors.grey.darken3,
          secondary: colors.amber.darken3,
          info: colors.teal.lighten1,
          warning: colors.amber.base,
          error: colors.deepOrange.accent4,
          success: colors.green.accent3
        },
        custom: {
          color: {
            background: {
              default: "#fff",
              paper: "#fff",
              paperOverlay: "#fff"
            },
            text: {
              primary: "#000",
              secondary: "rgba(0, 0, 0, 0.7)",
              disabled: "rgba(0, 0, 0, 0.5)",
              hint: "rgba(0, 0, 0, 0.5)",
              icon: "rgba(0, 0, 0, 0.5)"
            }
          }
        }
      }
    }
  },
};

【问题讨论】:

  • 您能否向我们提供有关您的nuxt.config.jspackage.json 文件的更多信息?
  • 你有this.$router.push({ path: '/path' })的文件呢?

标签: javascript vue.js nuxt.js


【解决方案1】:

得到Nuxt error : nodeOps.tagName(...) 以及以下vm undefined 错误: [Vue warn]: Error in render: "TypeError: _vm is undefined" (found in <Root>)

在我的一个组件中将v-if 替换为v-show 后,它得到了解决,我一直在提取服务器端异步数据并使用vuex getter(状态也在服务器端修改)来修改模板.

【讨论】:

    【解决方案2】:

    看起来您使用的是旧版本的 Node? https://github.com/nuxt/nuxt.js/issues/2385#issuecomment-358111543

    尝试将其升级到最新的 LTS aka 14,并仔细检查您是否也获得了最新版本的 Nuxt。

    【讨论】:

    • 谢谢,我有节点 14。我可以通过从 node_modules 更改 vue 源代码在开发模式下修复它,它只需要一些空检查。但它使用另一个我不知道的压缩文件进行生产,前提是我可以更改 webpack 中的文件....
    猜你喜欢
    • 1970-01-01
    • 2020-07-07
    • 2018-11-06
    • 1970-01-01
    • 1970-01-01
    • 2020-10-10
    • 2019-03-17
    • 2018-04-03
    • 1970-01-01
    相关资源
    最近更新 更多