[Vue warn]: Invalid prop: type check failed for prop "productCartData". Expected Object, got String with value "[object Object]"

Adlet

"cardData" sees but does not understand what elements the array consists of.

Everything works in vue-router v3.x.

My error:

[Vue warn]: Invalid prop: type check failed for prop "productCartData". Expected Object, got String with value "[object Object]". 
      at <ProductCart key=undefined productCartData="[object Object]" > 
      at <Cart cartData= ["[object Object]"]0: "[object Object]"length: 1__proto__: Array(0) onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > > 
      at <RouterView> 
  at <App>


<router-link class="nav-link" :to="{ name: 'cart', params: { cartData: cart } }">

Cart.vue

<ProductCart
  v-for="product in cartData"
  :key="product.id"
  :productCartData="product"
/>

props: {
    cartData: {
      type: Array,
      default() {
        return [];
      },
    },
  },

ProductCard.vue

props: {
    productCartData: {
      type: Object,
      default() {
        return {};
      },
    },
  },

Getter

 cart(state) {
            return state.cart;
          },

store.js

const store = createStore({
      state: {
        products: [],
        cart: [],
      },
    },
Toufiq Ahmed

You cant pass getter cart of array as params in router link. if you want access getter of cart into your component just access it directly in that component.

or you don't event need getter. just create a computed property in your component.

params can only be string or number and they need to be declared in router

read for params. https://next.router.vuejs.org/guide/essentials/dynamic-matching.html

to access objects arrays from store or data of components just use computed property.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Invalid prop: type check failed for prop "cellClass". Expected String with value "[object Object]", got Object

[Vue warn]: Invalid prop: type check failed for prop "page". Expected Number with value 0, got String with value ""

How to pass ref as prop: [Vue warn]: Invalid prop: type check failed for prop "containerRef". Expected Object, got HTMLDivElement?

Vue.js - Invalid prop: type check failed for prop "src". Expected String, Object, got Promise

Vue 3 Typescript props: [Vue warn]: Invalid prop: type check failed for prop "organisation". Expected Null | Boolean, got Object

vue.js vuetify test-utils warning : Vue warn]: Invalid prop: type check failed for prop "src". Expected String, got Object

Invalid prop: type check failed for prop "value". Expected Boolean, got String with value "0"

vue warning: Invalid prop: type check failed for prop "modalState". Expected Boolean, got Function

VueJs - Invalid prop: type check failed for prop "page". Expected DocumentPageDto, got Object

Invalid prop: type check failed for prop "data". Expected Array, got Object

Vuejs error, Invalid prop: type check failed for prop. Expected Date, got Number with value

Invalid prop: type check failed for prop "items". Expected Array, got String

[Vue warn]: Invalid prop: custom validator check failed for prop "time"

What is the cause of [Vue warn]: Invalid prop: custom validator check failed for prop "value"

Failed prop type: Invalid prop `match.params` of type `object` supplied to `Page`, expected `string`

Failed prop type: Invalid prop `children` of type `string` supplied to `DetailField`, expected `object`

GraphQL: Warning: Failed prop type: Invalid prop `query` of type `object` supplied to `StaticQuery`, expected `string`

Warning: Failed prop type: Invalid prop `items[0]` of type `string` supplied to `ImageGallery`, expected `object`

Failed prop type: Invalid prop `answer` of type `string` supplied to `AnswerItem`, expected `object`

Warning: Failed prop type: Invalid prop `value` of type `number` supplied to `TextInput`, expected `string`

laravel vue pagination return invalid prop type check failed for prop

Invalid prop type from router params, expected Number got String

Failed prop type: Invalid prop 'value'

Warning: Failed propType: Invalid prop of type `array` expected `object` with React

Warning: Failed prop type: Invalid prop `data` of type `object` supplied to `Carousel`, expected `array`

Failed prop type: Invalid prop `onClick` of type `object` supplied to `ButtonBase`, expected `function`

Failed prop type: Invalid prop `onClick` of type `object` supplied to `Button`, expected `function`

Why do I get Failed prop type: Invalid prop `onAnimationFinish` of type `object` supplied to `LottieView`, expected a `funtion`

Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`