Uncaught runtime errors: × ERROR Cannot read properties of undefined (reading 'forEach') TypeError: Cannot read properties of undefined (reading 'forEach') at Proxy.getAllTotal (webpack-internal:///./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Cart.vue?vue&type=script&lang=js:22:17) at Proxy.created (webpack-internal:///./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Cart.vue?vue&type=script&lang=js:16:10) at callWithErrorHandling (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:285:32) at callWithAsyncErrorHandling (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:293:17) at callHook (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:3305:3) at applyOptions (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:3229:5) at finishComponentSetup (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:6496:5) at setupStatefulComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:6424:5) at setupComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:6363:36) at mountComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4970:7)
时间: 2023-07-13 18:32:22 浏览: 1424
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#Object‘的解决方法
这个错误提示的意思是,在你的Vue组件的代码中,有一个变量或者属性是undefined类型,在代码中试图读取这个属性的时候,导致了运行时错误。
具体来说,这个错误发生在你的Cart.vue组件中的第22行,因为你试图在一个undefined类型的变量上调用forEach方法,但是undefined类型没有这个方法,所以导致了运行时错误。
为了解决这个问题,你需要检查一下你的代码,找到这个undefined类型的变量或者属性。你可以使用调试器或者console.log()来定位这个问题。一旦找到了这个undefined类型的变量或者属性,你需要确保在使用它之前进行了正确的初始化或者赋值操作。
总之,在编写Vue组件时,一定要小心处理变量和属性的类型,确保它们被正确地初始化和赋值,以避免出现这种运行时错误。
阅读全文