Search code examples
vuejs2vue-component

VUEJS - Why do I get: Uncaught TypeError: Right-hand side of 'instanceof'?


I am facing issue in vue.js about "Uncaught TypeError: Right-hand side of 'instanceof' is not an object".

I am using Vue 2.2.1 version following is my code snippet where I am getting this issue.

Vue.component('componentName', {
'template': ``,
 props: {
  contentTypeUid: {
    type: 'string',
    required: false
  },
  limit: {
    type: 'number',
    required: false,
    default: 10
  }
 },
 ......
});

While if instead of above following working without any issue, but I want to use above format as I need to specify some validations and default values on props.

Vue.component('componentName', {
'template': ``,
 props: ["contentTypeUid", "limit"],
 ......
});

Thanks.


Solution

  • Use:

    props: {
      contentTypeUid: {
        type: String, // not 'string'
        required: false
      },
      limit: {
        type: Number, // not 'number'
        required: false,
        default: 10
      }
     },